Skip to content

Commit

Permalink
Merge pull request #92 from Edvinas9/feature/AVB-697-add-ticket-type
Browse files Browse the repository at this point in the history
AVB-697 Ticket: Add ticketType
  • Loading branch information
tomrutherford-livestyled authored May 13, 2024
2 parents f7e2624 + 2bee249 commit bcd0fab
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 13 deletions.
15 changes: 10 additions & 5 deletions livestyled/models/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -225,7 +227,8 @@ def placeholder(
external_card_ref=None,
additional_fields=[],
printed=True,
timezone=None
timezone=None,
ticket_type='ticket'
)

@classmethod
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion livestyled/schemas/tests/fixtures/example_ticket.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
"dataType": "string",
"sort": 0
}
]
],
"ticketType": "ticket"
}
3 changes: 2 additions & 1 deletion livestyled/schemas/tests/fixtures/example_ticket_shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"status": "shared",
"shareCode": "ABCDEF12345",
"sharedAt": "2019-05-24T12:41:22+00:00",
"sharerEmail": "[email protected]"
"sharerEmail": "[email protected]",
"ticketType": "ticket"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"sharerEmail": "[email protected]",
"redeemerEmail": "[email protected]",
"redeemedAt": "2019-05-24T13:41:22+00:00",
"redeemer": "/v4/users/1234"
"redeemer": "/v4/users/1234",
"ticketType": "ticket"
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
"userEmail": "/v4/user_emails/328811",
"clientEmail": "[email protected]",
"clientId": "[email protected]"
}
},
"ticketType": "ticket"
}
11 changes: 9 additions & 2 deletions livestyled/schemas/tests/test_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def test_deserialize_ticket():
],
'printed': True,
'timezone': None,
'ticket_type': 'ticket',
}


Expand Down Expand Up @@ -150,6 +151,7 @@ def test_deserialize_ticket_shared():
'additional_fields': None,
'printed': True,
'timezone': None,
'ticket_type': 'ticket',
}


Expand Down Expand Up @@ -209,6 +211,7 @@ def test_deserialize_ticket_shared_redeemed():
'additional_fields': None,
'printed': True,
'timezone': None,
'ticket_type': 'ticket',
}


Expand Down Expand Up @@ -282,6 +285,7 @@ def test_deserialize_ticket_with_event_and_venue():
'additional_fields': None,
'printed': True,
'timezone': None,
'ticket_type': 'ticket',
}


Expand All @@ -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 == {
Expand Down Expand Up @@ -348,6 +353,7 @@ def test_serialize_ticket():
'additionalFields': [],
'printed': True,
'timezone': None,
'ticketType': 'ticket',
}


Expand Down Expand Up @@ -419,7 +425,8 @@ def get_ticket(data: Dict or None = None):
'sort': 0
}
],
'timezone': None
'timezone': None,
'ticket_type': 'ticket',
}

if data:
Expand Down
1 change: 1 addition & 0 deletions livestyled/schemas/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 5 additions & 1 deletion livestyled/tests/test_resource_client_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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'
}
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
skipsdist = True
envlist =
py38
py39

[testenv]
change_dir = {toxinidir}
Expand Down

0 comments on commit bcd0fab

Please sign in to comment.