fix(history): normalize legacy sorting keys
This commit is contained in:
1 parent
0aa1c202a2
commit
7f16c12255
3 files changed
+31
-8
No files matched your search
@@ -38,6 +38,18 @@ class CalculationHistoryTests(unittest.TestCase):
|
||||
self.assertFalse(store.delete_calculation(record_id))
|
||||
self.assertNotIn(record_id, [row["id"] for row in store.list_calculations()])
|
||||
|
||||
def test_admin_history_sorts_legacy_string_ids_without_type_errors(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
store = CalculationStore(sqlite_path=Path(directory) / "history.sqlite3")
|
||||
for kitten_id in ("12", 2, "not-an-id"):
|
||||
store.save(
|
||||
actor_id=99, source="vk",
|
||||
payload={"mode": "coaching", "escort_id": 1, "kitten_id": kitten_id},
|
||||
response={"mode": "coaching", "message": "расчёт", "result": {}},
|
||||
)
|
||||
rows = store.list_calculations(sort_by="kitten_id", descending=False)
|
||||
self.assertEqual([row["input"]["kitten_id"] for row in rows], [2, "12", "not-an-id"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user