Add database-backed manual order grid with automatic cell saving
This commit is contained in:
@@ -17,6 +17,7 @@ from settings_store import (
|
||||
SettingsNotInitialized,
|
||||
)
|
||||
from history_store import PostgresHistoryStore
|
||||
from manual_orders import ManualOrderStore, HEADERS, CellConflict
|
||||
|
||||
|
||||
@unittest.skipUnless(os.getenv("SETTINGS_TEST_DSN"), "SETTINGS_TEST_DSN test database is not configured")
|
||||
@@ -35,6 +36,8 @@ class RealPostgresTests(unittest.TestCase):
|
||||
self.store._connect = self.connect
|
||||
self.histories = PostgresHistoryStore({})
|
||||
self.histories._connect = self.connect
|
||||
self.manual = ManualOrderStore({})
|
||||
self.manual._connect = self.connect
|
||||
self.rows = [HEADER.copy(), ["APP_SETTINGS", "font", "한글 😊"],
|
||||
["ORDER_SINGLE", "B", "B-1"], ["ORDER_SINGLE", "A", "A-1"]]
|
||||
|
||||
@@ -110,6 +113,25 @@ class RealPostgresTests(unittest.TestCase):
|
||||
with self.assertRaises(SettingsAlreadyInitialized):
|
||||
self.histories.import_all(bundle, "test")
|
||||
|
||||
def test_manual_queue_conflicts_export_and_atomic_summary(self):
|
||||
self.histories.import_all({"kind": "corm-history", "sms": [], "manual": []}, "test")
|
||||
cells = ["2026-10-22 10:00:00"] + [""] * 14
|
||||
self.manual.import_source({"kind": "corm-manual-orders", "headers": HEADERS, "rows": [cells]}, "test")
|
||||
record = self.manual.list_rows()["rows"][0]
|
||||
change = {"id": record["id"], "column": 3, "value": "이름", "previous_value": ""}
|
||||
self.manual.patch_cells([change])
|
||||
with self.assertRaises(CellConflict):
|
||||
self.manual.patch_cells([{**change, "value": "다른 이름"}])
|
||||
# A lost successful response can be retried without reporting a conflict.
|
||||
self.manual.patch_cells([change])
|
||||
key = self.manual.append([cells], {"timestamp": cells[0], "customer_name": "테스트", "total_amount": 3500})
|
||||
histories = self.histories.list_records("manual")
|
||||
self.assertEqual(histories[0]["manual_order_key"], key)
|
||||
data, export_id = self.manual.export_and_archive("manual.xlsx")
|
||||
self.assertEqual(self.manual.exports(export_id), ("manual.xlsx", data))
|
||||
self.assertEqual(self.manual.list_rows()["rows"], [])
|
||||
self.assertEqual(len(self.manual.exports()), 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user