Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVB-759: Add ticket.aisle field #95

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions livestyled/models/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def __init__(
additional_fields=[],
printed=True,
timezone=None,
ticket_type='ticket'
ticket_type='ticket',
aisle=None,
):
self.id = id
self.external_ticket_id = external_ticket_id
Expand Down Expand Up @@ -172,6 +173,7 @@ def __init__(
self.printed = printed
self.timezone = timezone
self.ticket_type = ticket_type
self.aisle = aisle

@classmethod
def placeholder(
Expand Down Expand Up @@ -228,7 +230,8 @@ def placeholder(
additional_fields=[],
printed=True,
timezone=None,
ticket_type='ticket'
ticket_type='ticket',
aisle=None,
)

@classmethod
Expand Down Expand Up @@ -280,7 +283,8 @@ def create_new(
additional_fields=None,
printed=True,
timezone=None,
ticket_type='ticket'
ticket_type='ticket',
aisle=None,
):
if additional_fields is None:
additional_fields = []
Expand Down Expand Up @@ -334,7 +338,8 @@ def create_new(
additional_fields=additional_fields,
printed=printed,
timezone=timezone,
ticket_type=ticket_type
ticket_type=ticket_type,
aisle=aisle,
)
if isinstance(user, (str, int)):
user = User.placeholder(id=user)
Expand Down Expand Up @@ -403,7 +408,7 @@ def diff(self, existing):
'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', 'ticket_type'
'additional_fields', 'printed', 'timezone', 'ticket_type', 'aisle'
)
for field in fields:
current = getattr(existing, 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 @@ -47,5 +47,6 @@
"sort": 0
}
],
"ticketType": "ticket"
"ticketType": "ticket",
"aisle": "aisle"
}
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 @@ -21,5 +21,6 @@
"shareCode": "ABCDEF12345",
"sharedAt": "2019-05-24T12:41:22+00:00",
"sharerEmail": "[email protected]",
"ticketType": "ticket"
"ticketType": "ticket",
"aisle": "aisle"
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"redeemerEmail": "[email protected]",
"redeemedAt": "2019-05-24T13:41:22+00:00",
"redeemer": "/v4/users/1234",
"ticketType": "ticket"
"ticketType": "ticket",
"aisle": "aisle"
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@
"clientEmail": "[email protected]",
"clientId": "[email protected]"
},
"ticketType": "ticket"
"ticketType": "ticket",
"aisle": "aisle"
}
7 changes: 7 additions & 0 deletions livestyled/schemas/tests/test_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def test_deserialize_ticket():
'printed': True,
'timezone': None,
'ticket_type': 'ticket',
'aisle': 'aisle',
}


Expand Down Expand Up @@ -152,6 +153,7 @@ def test_deserialize_ticket_shared():
'printed': True,
'timezone': None,
'ticket_type': 'ticket',
'aisle': 'aisle',
}


Expand Down Expand Up @@ -212,6 +214,7 @@ def test_deserialize_ticket_shared_redeemed():
'printed': True,
'timezone': None,
'ticket_type': 'ticket',
'aisle': 'aisle',
}


Expand Down Expand Up @@ -286,6 +289,7 @@ def test_deserialize_ticket_with_event_and_venue():
'printed': True,
'timezone': None,
'ticket_type': 'ticket',
'aisle': 'aisle',
}


Expand All @@ -300,6 +304,7 @@ def test_serialize_ticket():
event=9999,
user=8888,
ticket_type='ticket',
aisle='aisle',
)
serialized_ticket = TicketSchema().dump(ticket)
assert serialized_ticket == {
Expand Down Expand Up @@ -354,6 +359,7 @@ def test_serialize_ticket():
'printed': True,
'timezone': None,
'ticketType': 'ticket',
'aisle': 'aisle',
}


Expand Down Expand Up @@ -427,6 +433,7 @@ def get_ticket(data: Dict or None = None):
],
'timezone': None,
'ticket_type': 'ticket',
'aisle': 'aisle',
}

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 @@ -102,3 +102,4 @@ class Meta:
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)
aisle = fields.String(data_key='aisle', required=False, allow_none=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's nullable on apiv3 so allow_none should probably be True here

9 changes: 6 additions & 3 deletions livestyled/tests/test_resource_client_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ 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'
assert ticket.ticket_type == 'ticket'
assert ticket.aisle is None


def test_get_ticket_shared(requests_mock):
Expand Down Expand Up @@ -104,7 +105,8 @@ 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'
assert ticket.ticket_type == 'ticket'
assert ticket.aisle is None


def test_get_ticket_shared_redeemed(requests_mock):
Expand Down Expand Up @@ -152,7 +154,8 @@ 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'
assert ticket.ticket_type == 'ticket'
assert ticket.aisle is None


def test_create_ticket(requests_mock):
Expand Down
Loading