Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion shared/reports/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def build_from_encoded_data(cls, sessions_array: Union[dict, list]):
extra=dict(sessions_array=sessions_array),
)
sessions_array["meta"] = {
"session_count": max(sessions_array.keys()) + 1
"session_count": int(max(sessions_array.keys())) + 1
}
meta_info = sessions_array.pop("meta")
session_count = meta_info["session_count"]
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/reports/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ class TestSessionTotalsArray(object):
"meta": {"session_count": 5},
"4": [0, 35, 35, 0, 0, "100", 5, 0, 0, 0, 0, 0, 0],
}
encoded_obj_string_no_meta = {
"4": [0, 35, 35, 0, 0, "100", 5, 0, 0, 0, 0, 0, 0],
}

def test_decode_session_totals_array_from_legacy(self):
expected = SessionTotalsArray(
Expand Down Expand Up @@ -230,6 +233,16 @@ def test_decode_session_totals_array_string_indexes(self):
assert expected.session_count == result.session_count
assert expected.non_null_items == result.non_null_items

def test_decode_session_totals_array_string_indexes_no_meta(self):
encoded_obj_copy = deepcopy(self.encoded_obj_string_no_meta)
expected = SessionTotalsArray(
session_count=5,
non_null_items={4: [0, 35, 35, 0, 0, "100", 5, 0, 0, 0, 0, 0, 0]},
)
result = SessionTotalsArray.build_from_encoded_data(encoded_obj_copy)
assert expected.session_count == result.session_count
assert expected.non_null_items == result.non_null_items

def test_decode_session_totals_array_no_meta(self):
encoded_obj_copy = deepcopy(self.encoded_obj)
encoded_obj_copy.pop("meta")
Expand Down