Example #1
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']
Example #2
0
    def test_validator_missing_price(self):
        ticket = Ticket(username=USERNAME, user_id=USER_ID)
        ticket.category = 1
        ticket.date = 508
        ticket.quantity = 2
        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'] == '價錢未填喔'