Пример #1
0
    def test_validator_error_message(self):
        ticket = Ticket(username=USERNAME, user_id=USER_ID)
        expected = '門票類別未填喔\n日期未填喔\n價錢未填喔\n數量未填喔'
        result = ticket.validate()
        assert result['status'] is False
        assert result['info'] == expected

        validator = ItemValidator(ticket.to_dict())
        result = validator.check_ticket()
        assert result['status'] is False
        assert result['info'] == expected
Пример #2
0
    def test_validator_success(self):
        ticket = Ticket(username=USERNAME, user_id=USER_ID)
        ticket.category = 1
        ticket.date = 508
        ticket.price_id = 1
        ticket.quantity = 2
        ticket.status = 1
        result = ticket.validate()
        assert result['status']

        validator = ItemValidator(ticket.to_dict())
        result = validator.check_ticket()
        assert result['status']
Пример #3
0
    def test_validator_missing_quantity(self):
        ticket = Ticket(username=USERNAME, user_id=USER_ID)
        ticket.category = 1
        ticket.date = 508
        ticket.price_id = 1
        ticket.status = 1
        result = ticket.validate()
        assert result['status'] is False
        assert result['info'] == '數量未填喔'

        validator = ItemValidator(ticket.to_dict())
        result = validator.check_ticket()
        assert result['status'] is False
        assert result['info'] == '數量未填喔'
Пример #4
0
 def validate_wishlist(self) -> dict:
     return ItemValidator(self.to_dict()).check_wishlist()
Пример #5
0
 def validate(self) -> dict:
     return ItemValidator(self.to_dict()).check_ticket()
Пример #6
0
 def validate(self) -> dict:
     return ItemValidator(self.to_dict()).check_query()