Skip to content

Commit

Permalink
Expose floor info (#90)
Browse files Browse the repository at this point in the history
For multi-floor charts, floor information is included in chart reports.

Co-authored-by: Steve Chaloner <[email protected]>
  • Loading branch information
schaloner and Steve Chaloner authored Oct 2, 2024
1 parent c842bbb commit 5df54ea
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 359 deletions.
2 changes: 2 additions & 0 deletions seatsio/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ def __init__(self, item_data):
self.is_companion_seat = item_data.get("isCompanionSeat")
self.has_restricted_view = item_data.get("hasRestrictedView")
self.zone = item_data.get("zone")
self.floor = item_data.get("floor")



class EventReport:
Expand Down
71 changes: 71 additions & 0 deletions tests/reports/charts/testChartReports.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_reportItemProperties(self, update_chart, get_report):
assert_that(report_item.is_accessible).is_not_none()
assert_that(report_item.is_companion_seat).is_not_none()
assert_that(report_item.has_restricted_view).is_not_none()
assert_that(report_item.floor).is_none()

@parameterized.expand([
[
Expand Down Expand Up @@ -110,6 +111,29 @@ def testByLabel(self, update_chart, get_report):
assert_that(report.get("A-1")).has_size(1)
assert_that(report.get("A-2")).has_size(1)

@parameterized.expand([
[
lambda instance, chart_key: {},
lambda instance, chart_key: instance.client.charts.reports.by_label(chart_key=chart_key)
],
[
lambda instance, chart_key: instance.create_draft_chart(chart_key),
lambda instance, chart_key: instance.client.charts.reports.by_label(chart_key=chart_key, version='draft')
]
])
def testByLabelWithFloors(self, update_chart, get_report):
chart_key = self.create_test_chart_with_floors()
update_chart(self, chart_key)

report = get_report(self, chart_key)

assert_that(report).is_instance(ChartReport)
assert_that(report.get("S1-A-1")[0].floor).is_equal_to({"name": "1", "displayName": "Floor 1"})
assert_that(report.get("S1-A-2")[0].floor).is_equal_to({"name": "1", "displayName": "Floor 1"})
assert_that(report.get("S2-B-1")[0].floor).is_equal_to({"name": "2", "displayName": "Floor 2"})
assert_that(report.get("S2-B-2")[0].floor).is_equal_to({"name": "2", "displayName": "Floor 2"})


@parameterized.expand([
[
lambda instance, chart_key: {},
Expand All @@ -131,6 +155,29 @@ def testByObjectType(self, update_chart, get_report):
assert_that(report.get("seat")).has_size(32)
assert_that(report.get("generalAdmission")).has_size(2)

@parameterized.expand([
[
lambda instance, chart_key: {},
lambda instance, chart_key: instance.client.charts.reports.by_object_type(chart_key=chart_key)
],
[
lambda instance, chart_key: instance.create_draft_chart(chart_key),
lambda instance, chart_key: instance.client.charts.reports.by_object_type(chart_key=chart_key,
version='draft')
]
])
def testByObjectTypeWithFloors(self, update_chart, get_report):
chart_key = self.create_test_chart_with_floors()
update_chart(self, chart_key)

report = get_report(self, chart_key)

assert_that(report).is_instance(ChartReport)
assert_that(report.get("seat")[0].floor).is_equal_to({"name": "1", "displayName": "Floor 1"})
assert_that(report.get("seat")[1].floor).is_equal_to({"name": "1", "displayName": "Floor 1"})
assert_that(report.get("seat")[2].floor).is_equal_to({"name": "2", "displayName": "Floor 2"})
assert_that(report.get("seat")[3].floor).is_equal_to({"name": "2", "displayName": "Floor 2"})

@parameterized.expand([
[
lambda instance, chart_key: {},
Expand Down Expand Up @@ -240,6 +287,30 @@ def testByZone(self, update_chart, get_report):
assert_that(report.get("finishline")).has_size(2865)
assert_that(report.get("NO_ZONE")).has_size(0)


@parameterized.expand([
[
lambda instance, chart_key: {},
lambda instance, chart_key: instance.client.charts.reports.by_section(chart_key=chart_key)
],
[
lambda instance, chart_key: instance.create_draft_chart(chart_key),
lambda instance, chart_key: instance.client.charts.reports.by_section(chart_key=chart_key,
version='draft')
]
])
def testBySectionWithFloors(self, update_chart, get_report):
chart_key = self.create_test_chart_with_floors()
update_chart(self, chart_key)

report = get_report(self, chart_key)

assert_that(report).is_instance(ChartReport)
assert_that(report.get("S1")[0].floor).is_equal_to({"name": "1", "displayName": "Floor 1"})
assert_that(report.get("S1")[1].floor).is_equal_to({"name": "1", "displayName": "Floor 1"})
assert_that(report.get("S2")[0].floor).is_equal_to({"name": "2", "displayName": "Floor 2"})
assert_that(report.get("S2")[1].floor).is_equal_to({"name": "2", "displayName": "Floor 2"})

def create_draft_chart(self, chart_key):
self.client.events.create(chart_key)
self.client.charts.update(chart_key, "Foo")
Loading

0 comments on commit 5df54ea

Please sign in to comment.