diff --git a/livestyled/models/ticket.py b/livestyled/models/ticket.py index e6384a3..b6aaf8b 100644 --- a/livestyled/models/ticket.py +++ b/livestyled/models/ticket.py @@ -58,7 +58,8 @@ def __init__( external_card_ref=None, additional_fields=[], printed=True, - timezone=None + timezone=None, + ticket_type='ticket' ): self.id = id self.external_ticket_id = external_ticket_id @@ -170,6 +171,7 @@ def __init__( self.additional_fields = additional_fields self.printed = printed self.timezone = timezone + self.ticket_type = ticket_type @classmethod def placeholder( @@ -225,7 +227,8 @@ def placeholder( external_card_ref=None, additional_fields=[], printed=True, - timezone=None + timezone=None, + ticket_type='ticket' ) @classmethod @@ -276,7 +279,8 @@ def create_new( external_card_ref=None, additional_fields=None, printed=True, - timezone=None + timezone=None, + ticket_type='ticket' ): if additional_fields is None: additional_fields = [] @@ -329,7 +333,8 @@ def create_new( external_card_ref=external_card_ref, additional_fields=additional_fields, printed=printed, - timezone=timezone + timezone=timezone, + ticket_type=ticket_type ) if isinstance(user, (str, int)): user = User.placeholder(id=user) @@ -398,7 +403,7 @@ def diff(self, other): 'redeemer_email', 'parent_ticket', 'shared_at', 'legal_long_text', 'legal_short_text', 'map_url', 'map_image_url', 'ticket_integration', 'entrance', 'row', 'section', 'price_code', 'price_type', 'external_customer_ref', 'venue', 'event', 'event_date', 'currency', 'external_card_ref', - 'additional_fields', 'printed', 'timezone' + 'additional_fields', 'printed', 'timezone', 'ticket_type' ) for field in fields: if getattr(self, field) != getattr(other, field): diff --git a/livestyled/schemas/tests/fixtures/example_ticket.json b/livestyled/schemas/tests/fixtures/example_ticket.json index 1527327..09ccf32 100644 --- a/livestyled/schemas/tests/fixtures/example_ticket.json +++ b/livestyled/schemas/tests/fixtures/example_ticket.json @@ -46,5 +46,6 @@ "dataType": "string", "sort": 0 } - ] + ], + "ticketType": "ticket" } diff --git a/livestyled/schemas/tests/fixtures/example_ticket_shared.json b/livestyled/schemas/tests/fixtures/example_ticket_shared.json index 5839428..bcfba43 100644 --- a/livestyled/schemas/tests/fixtures/example_ticket_shared.json +++ b/livestyled/schemas/tests/fixtures/example_ticket_shared.json @@ -20,5 +20,6 @@ "status": "shared", "shareCode": "ABCDEF12345", "sharedAt": "2019-05-24T12:41:22+00:00", - "sharerEmail": "test@livestyled.com" + "sharerEmail": "test@livestyled.com", + "ticketType": "ticket" } \ No newline at end of file diff --git a/livestyled/schemas/tests/fixtures/example_ticket_shared_redeemed.json b/livestyled/schemas/tests/fixtures/example_ticket_shared_redeemed.json index 03f8e15..46132dc 100644 --- a/livestyled/schemas/tests/fixtures/example_ticket_shared_redeemed.json +++ b/livestyled/schemas/tests/fixtures/example_ticket_shared_redeemed.json @@ -23,5 +23,6 @@ "sharerEmail": "test@livestyled.com", "redeemerEmail": "someoneelse@livestyled.com", "redeemedAt": "2019-05-24T13:41:22+00:00", - "redeemer": "/v4/users/1234" + "redeemer": "/v4/users/1234", + "ticketType": "ticket" } \ No newline at end of file diff --git a/livestyled/schemas/tests/fixtures/example_ticket_with_event_and_venue.json b/livestyled/schemas/tests/fixtures/example_ticket_with_event_and_venue.json index 57061b9..f9e1f7d 100644 --- a/livestyled/schemas/tests/fixtures/example_ticket_with_event_and_venue.json +++ b/livestyled/schemas/tests/fixtures/example_ticket_with_event_and_venue.json @@ -52,5 +52,6 @@ "userEmail": "/v4/user_emails/328811", "clientEmail": "hakan.goransson@stockholmlive.com", "clientId": "hakan.goransson@stockholmlive.com" - } + }, + "ticketType": "ticket" } \ No newline at end of file diff --git a/livestyled/schemas/tests/test_ticket.py b/livestyled/schemas/tests/test_ticket.py index d6aed18..09eee6e 100644 --- a/livestyled/schemas/tests/test_ticket.py +++ b/livestyled/schemas/tests/test_ticket.py @@ -91,6 +91,7 @@ def test_deserialize_ticket(): ], 'printed': True, 'timezone': None, + 'ticket_type': 'ticket', } @@ -150,6 +151,7 @@ def test_deserialize_ticket_shared(): 'additional_fields': None, 'printed': True, 'timezone': None, + 'ticket_type': 'ticket', } @@ -209,6 +211,7 @@ def test_deserialize_ticket_shared_redeemed(): 'additional_fields': None, 'printed': True, 'timezone': None, + 'ticket_type': 'ticket', } @@ -282,6 +285,7 @@ def test_deserialize_ticket_with_event_and_venue(): 'additional_fields': None, 'printed': True, 'timezone': None, + 'ticket_type': 'ticket', } @@ -294,7 +298,8 @@ def test_serialize_ticket(): client_name='Test Testerson', entrance='Entrance A', event=9999, - user=8888 + user=8888, + ticket_type='ticket', ) serialized_ticket = TicketSchema().dump(ticket) assert serialized_ticket == { @@ -348,6 +353,7 @@ def test_serialize_ticket(): 'additionalFields': [], 'printed': True, 'timezone': None, + 'ticketType': 'ticket', } @@ -419,7 +425,8 @@ def get_ticket(data: Dict or None = None): 'sort': 0 } ], - 'timezone': None + 'timezone': None, + 'ticket_type': 'ticket', } if data: diff --git a/livestyled/schemas/ticket.py b/livestyled/schemas/ticket.py index 3232c1b..2ff0851 100644 --- a/livestyled/schemas/ticket.py +++ b/livestyled/schemas/ticket.py @@ -101,3 +101,4 @@ class Meta: many=True) printed = fields.Boolean(allow_none=True, required=False, missing=True) timezone = fields.String(allow_none=True, required=False, missing=None) + ticket_type = fields.String(data_key='ticketType', required=False, allow_none=False) diff --git a/livestyled/tests/test_resource_client_ticket.py b/livestyled/tests/test_resource_client_ticket.py index 1229626..49b5f30 100644 --- a/livestyled/tests/test_resource_client_ticket.py +++ b/livestyled/tests/test_resource_client_ticket.py @@ -57,6 +57,7 @@ def test_get_ticket(requests_mock): assert ticket.venue_name is None assert ticket.venue_room is None assert ticket.redeemed_at is None + assert ticket.ticket_type is 'ticket' def test_get_ticket_shared(requests_mock): @@ -103,6 +104,7 @@ def test_get_ticket_shared(requests_mock): assert ticket.venue_name is None assert ticket.venue_room is None assert ticket.redeemed_at is None + assert ticket.ticket_type is 'ticket' def test_get_ticket_shared_redeemed(requests_mock): @@ -150,6 +152,7 @@ def test_get_ticket_shared_redeemed(requests_mock): assert ticket.venue_name is None assert ticket.venue_room is None assert ticket.redeemed_at == datetime(2019, 5, 24, 13, 41, 22, tzinfo=timezone(timedelta(0), '+0000')) + assert ticket.ticket_type is 'ticket' def test_create_ticket(requests_mock): @@ -192,5 +195,6 @@ def test_create_ticket(requests_mock): 'user': '/v4/users/1234', 'ticketIntegration': '/v4/ticket_integrations/99', 'additionalFields': [], - 'printed': True + 'printed': True, + 'ticketType': 'ticket' } diff --git a/tox.ini b/tox.ini index 0debdee..a4045c5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] skipsdist = True envlist = - py38 + py39 [testenv] change_dir = {toxinidir}