fix(admin): backfill legacy inspection scores
This commit is contained in:
1 parent
6235368baf
commit
a0e4a47522
2 files changed
+46
No files matched your search
@@ -50,6 +50,24 @@ class CalculationHistoryTests(unittest.TestCase):
|
||||
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"])
|
||||
|
||||
def test_admin_history_backfills_legacy_inspection_breakdown(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
store = CalculationStore(sqlite_path=Path(directory) / "history.sqlite3")
|
||||
store.save(
|
||||
actor_id=99,
|
||||
source="vk",
|
||||
payload={
|
||||
"mode": "inspection", "character_name": "Белка", "character_id": 1,
|
||||
"place": "дупло", "inspections": 17,
|
||||
"resources": [["паутина", 1], ["мох", 1], ["мох", 2]],
|
||||
},
|
||||
response={"mode": "inspection", "message": "старый отчёт", "result": {"points": 53}},
|
||||
)
|
||||
result = store.list_calculations()[0]["result"]
|
||||
self.assertEqual(result["inspection_points"], 34)
|
||||
self.assertEqual(result["points"], 50)
|
||||
self.assertEqual(result["resource_points"][0]["points"], 7)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in new issue
Block a user