Add database-backed manual order grid with automatic cell saving
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
// Optional browser QA: NODE_PATH must contain an installed playwright package.
|
||||
const {chromium} = require('playwright');
|
||||
const http = require('node:http');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const assert = require('node:assert/strict');
|
||||
const {execFileSync} = require('node:child_process');
|
||||
const root = path.resolve(__dirname, '..');
|
||||
const headers = JSON.parse(execFileSync('python', ['-c', 'import json; from manual_orders import HEADERS; print(json.dumps(HEADERS))'], {cwd: root, encoding: 'utf8'}));
|
||||
const template = fs.readFileSync(path.join(root, 'templates/index.html'), 'utf8');
|
||||
const markup = template.match(/{% if manual_orders_backend == 'postgres' %}([\s\S]*?){% else %}/)[1];
|
||||
const html = `<!doctype html><meta charset="utf-8"><link rel="stylesheet" href="/static/css/styles.css"><link rel="stylesheet" href="/static/css/manual_grid.css"><style>body{margin:0;font-family:Arial,sans-serif}section{height:94vh;width:100%}</style><section id="manual-tab" class="active">${markup}</section><script src="/static/js/manual_grid.js"></script>`;
|
||||
let rows = [1, 2].map(id => ({id, version: 1, cells: headers.map((_, c) => c === 0 ? '2026-10-22 10:00:00' : c === 3 ? `테스트 고객 ${id}` : c === 4 ? 'TEST-0001' : c === 8 ? '00123' : '')}));
|
||||
let failNext = false, conflictNext = false, exported = false, nextId = 3;
|
||||
const server = http.createServer(async (req, res) => {
|
||||
const reply = (code, data) => { res.writeHead(code, {'Content-Type': 'application/json'}); res.end(JSON.stringify(data)); };
|
||||
if (req.url === '/') {res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});res.end(html);return;}
|
||||
if (req.url.startsWith('/static/')) {res.writeHead(200, {'Content-Type': req.url.endsWith('.css') ? 'text/css' : 'application/javascript'});res.end(fs.readFileSync(path.join(root, req.url)));return;}
|
||||
if (req.url === '/api/manual/orders' && req.method === 'GET') return reply(200, {headers, rows});
|
||||
if (req.url === '/api/manual/orders' && req.method === 'POST') {rows.push({id: nextId++, version: 1, cells: headers.map(() => '')});return reply(200, {status: 'success'});}
|
||||
if (req.url === '/api/manual/orders/cells') {
|
||||
let body='';for await(const chunk of req)body+=chunk;
|
||||
const changes=JSON.parse(body).changes;
|
||||
if(failNext){failNext=false;return reply(503,{detail:'테스트 저장 장애'});}
|
||||
if(conflictNext){conflictNext=false;const change=changes[0], row=rows.find(r=>r.id===change.id);row.cells[change.column]='다른 사용자의 최신값';row.version++;return reply(409,{detail:{message:'동시 수정 충돌',conflicts:[{id:row.id,column:change.column,value:row.cells[change.column]}]}});}
|
||||
const updated=new Set();
|
||||
for(const c of changes){const row=rows.find(r=>r.id===c.id);assert(row);assert(row.cells[c.column]===c.previous_value||row.cells[c.column]===c.value);row.cells[c.column]=c.value;updated.add(row.id);}
|
||||
for(const id of updated)rows.find(r=>r.id===id).version++;
|
||||
return reply(200,{rows:rows.filter(r=>updated.has(r.id))});
|
||||
}
|
||||
if(req.url==='/api/manual/orders/archive'){
|
||||
let body='';for await(const chunk of req)body+=chunk;const selected=JSON.parse(body).rows;
|
||||
for(const row of selected)assert.equal(rows.find(r=>r.id===row.id).version,row.version);
|
||||
rows=rows.filter(r=>!selected.some(s=>s.id===r.id));return reply(200,{status:'success'});
|
||||
}
|
||||
if(req.url==='/api/sheet/download_and_clear'){exported=true;rows=[];res.writeHead(200,{'Content-Type':'application/octet-stream','Content-Disposition':"attachment; filename*=UTF-8''manual.xlsx"});res.end('exported rows');return;}
|
||||
if(req.url==='/api/manual/orders/exports')return reply(200,exported?[{id:'test-export',filename:'manual.xlsx'}]:[]);
|
||||
if(req.url==='/api/manual/orders/exports/test-export'){res.writeHead(200,{'Content-Disposition':'attachment; filename="manual.xlsx"'});res.end('exported rows');return;}
|
||||
reply(404,{});
|
||||
});
|
||||
(async()=>{
|
||||
await new Promise(resolve=>server.listen(0,'127.0.0.1',resolve));
|
||||
const browser=await chromium.launch({headless:true,executablePath:process.env.CORM_TEST_BROWSER||'C:/Program Files/Google/Chrome/Application/chrome.exe'});
|
||||
try{
|
||||
const page=await browser.newPage({viewport:{width:1440,height:900},acceptDownloads:true});
|
||||
const errors=[];page.on('pageerror',e=>errors.push(e.message));
|
||||
await page.goto(`http://127.0.0.1:${server.address().port}`);
|
||||
await page.waitForSelector('td[data-id="1"]');
|
||||
const cell=(id,column)=>page.locator(`td[data-id="${id}"][data-column="${column}"]`);
|
||||
const saved=()=>page.waitForFunction(()=>document.getElementById('manual-save-status').textContent==='모든 변경사항 저장됨');
|
||||
await cell(1,3).fill('자동 저장 고객');await saved();assert.equal(rows[0].cells[3],'자동 저장 고객');
|
||||
await page.reload();await page.waitForSelector('td[data-id="1"]');assert.equal(await cell(1,3).textContent(),'자동 저장 고객');
|
||||
await cell(1,3).focus();await page.keyboard.press('Tab');assert.equal(await page.locator(':focus').getAttribute('data-column'),'4');
|
||||
await cell(1,4).evaluate(td=>{const data=new DataTransfer();data.setData('text/plain','CODE-A\t상품 A\nCODE-B\t상품 B');td.dispatchEvent(new ClipboardEvent('paste',{clipboardData:data,bubbles:true,cancelable:true}));});
|
||||
await saved();assert.equal(rows[1].cells[5],'상품 B');
|
||||
failNext=true;await cell(1,3).fill('장애 후 재시도');await page.waitForSelector('#manual-save-retry:not([hidden])');
|
||||
assert.equal(await cell(1,3).textContent(),'장애 후 재시도');await page.click('#manual-save-retry');await saved();assert.equal(rows[0].cells[3],'장애 후 재시도');
|
||||
conflictNext=true;await cell(1,3).fill('충돌 입력');await page.waitForSelector('#manual-save-retry:not([hidden])');
|
||||
page.once('dialog',d=>d.dismiss());await page.click('#manual-save-retry');await saved();assert.equal(await cell(1,3).textContent(),'다른 사용자의 최신값');
|
||||
await page.locator('body').click({position:{x:1300,y:800}});
|
||||
fs.mkdirSync(path.join(root,'.cache'),{recursive:true});await page.screenshot({path:path.join(root,'.cache/manual-grid-qa.png')});
|
||||
await page.click('#manual-add-row');await page.waitForSelector('td[data-id="3"]');
|
||||
await cell(3,3).fill('삭제 전 수정');await page.check('input[data-row-id="3"]');
|
||||
page.once('dialog',d=>d.accept());await page.click('#manual-delete-rows');await page.waitForFunction(()=>document.querySelectorAll('#manual-grid tbody tr').length===2);
|
||||
page.once('dialog',d=>d.accept());const download=page.waitForEvent('download');await page.click('#manual-download');await download;
|
||||
await page.waitForFunction(()=>document.getElementById('manual-grid-empty').hidden===false);
|
||||
await page.click('#manual-exports summary');await page.waitForSelector('#manual-export-list a');assert.equal(await page.locator('#manual-export-list a').textContent(),'manual.xlsx');
|
||||
assert.deepEqual(errors,[]);console.log('Browser QA passed: autosave, reload, Tab, multi-cell paste, failure retry, conflict, row add/delete, export and redownload link.');
|
||||
}finally{await browser.close();server.close();}
|
||||
})().catch(error=>{console.error(error);server.close();process.exitCode=1;});
|
||||
@@ -172,6 +172,9 @@ class ApiTests(unittest.IsolatedAsyncioTestCase):
|
||||
histories = patch.object(main, "HISTORY_BACKEND", "google")
|
||||
histories.start()
|
||||
self.addCleanup(histories.stop)
|
||||
manual = patch.object(main, "MANUAL_ORDERS_BACKEND", "google")
|
||||
manual.start()
|
||||
self.addCleanup(manual.stop)
|
||||
self.directory = tempfile.TemporaryDirectory()
|
||||
self.cache = runtime.SettingsCache(Path(self.directory.name) / "settings.json", "test")
|
||||
self.cache_patch = patch.object(main, "_settings_cache", self.cache)
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
"""Manual queue fidelity, atomic autosave, export recovery and API isolation."""
|
||||
|
||||
import io
|
||||
import json
|
||||
import unittest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from openpyxl import load_workbook
|
||||
|
||||
import main
|
||||
from manual_orders import HEADERS, CellConflict, ManualOrderStore, build_xlsx, validate_source
|
||||
from test_google_resilience import request
|
||||
|
||||
|
||||
CELLS = ["2026-10-22 10:00:00", "", "3500", "테스트", "TEST-1", "상품", "2", "주소", "00123", "010-0000-0000", "010-0000-0000", "요청", "", "수동발주", "비고"]
|
||||
|
||||
|
||||
class FormatTests(unittest.TestCase):
|
||||
def test_excel_keeps_column_order_leading_zeros_and_literal_formulas(self):
|
||||
cells = CELLS.copy()
|
||||
cells[14] = '=HYPERLINK("https://example.invalid","text")'
|
||||
book = load_workbook(io.BytesIO(build_xlsx(HEADERS, [cells])))
|
||||
sheet = book.active
|
||||
self.assertEqual(list(next(sheet.values)), HEADERS)
|
||||
self.assertEqual(sheet["I2"].value, "00123")
|
||||
self.assertEqual(sheet["G2"].value, 2)
|
||||
self.assertEqual(sheet["O2"].data_type, "s")
|
||||
self.assertEqual(sheet["O2"].value, cells[14])
|
||||
|
||||
def test_source_padding_keeps_blank_rows_and_extra_columns(self):
|
||||
headers, rows = validate_source({"kind": "corm-manual-orders", "headers": HEADERS + ["추가 열"], "rows": [[], CELLS + ["추가 값"]]})
|
||||
self.assertEqual(len(rows[0]), 16)
|
||||
self.assertEqual(rows[1][-1], "추가 값")
|
||||
|
||||
|
||||
class StoreTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.store = ManualOrderStore({})
|
||||
self.connection = MagicMock()
|
||||
self.cursor = self.connection.cursor.return_value.__enter__.return_value
|
||||
connect = patch.object(self.store, "_connect", return_value=self.connection)
|
||||
connect.start()
|
||||
self.addCleanup(connect.stop)
|
||||
|
||||
def test_same_cell_conflict_aborts_entire_batch(self):
|
||||
self.cursor.fetchall.return_value = [(1, CELLS.copy(), 2)]
|
||||
with self.assertRaises(CellConflict):
|
||||
self.store.patch_cells([{"id": 1, "column": 3, "value": "새 이름", "previous_value": "다른 이름"}])
|
||||
self.assertIs(self.connection.__exit__.call_args.args[0], CellConflict)
|
||||
self.assertEqual(self.cursor.execute.call_count, 1)
|
||||
|
||||
def test_retry_of_already_saved_value_succeeds_and_other_cells_are_preserved(self):
|
||||
self.cursor.fetchall.return_value = [(1, CELLS.copy(), 2)]
|
||||
self.cursor.fetchone.return_value = (3,)
|
||||
rows = self.store.patch_cells([{"id": 1, "column": 3, "value": CELLS[3], "previous_value": "old"}])
|
||||
self.assertEqual(rows[0]["cells"][8], "00123")
|
||||
self.assertEqual(rows[0]["version"], 3)
|
||||
|
||||
def test_missing_or_archived_row_is_not_recreated_by_autosave(self):
|
||||
self.cursor.fetchall.return_value = []
|
||||
with self.assertRaises(LookupError):
|
||||
self.store.patch_cells([{"id": 1, "column": 3, "value": "new", "previous_value": "old"}])
|
||||
|
||||
def test_order_and_summary_share_one_transaction(self):
|
||||
self.cursor.fetchone.return_value = (HEADERS,)
|
||||
self.cursor.execute.side_effect = [None, None, RuntimeError("summary insert failed")]
|
||||
with self.assertRaises(RuntimeError):
|
||||
self.store.append([CELLS], {"timestamp": CELLS[0], "customer_name": "테스트", "total_amount": 3500})
|
||||
self.assertIs(self.connection.__exit__.call_args.args[0], RuntimeError)
|
||||
|
||||
def test_export_failure_never_archives_rows(self):
|
||||
self.cursor.fetchone.return_value = (HEADERS,)
|
||||
self.cursor.fetchall.return_value = [(1, CELLS)]
|
||||
with patch("manual_orders.build_xlsx", side_effect=RuntimeError("file failed")), self.assertRaises(RuntimeError):
|
||||
self.store.export_and_archive("test.xlsx")
|
||||
self.assertEqual(self.cursor.execute.call_count, 2)
|
||||
|
||||
def test_export_is_archived_with_exact_row_ids_for_redownload(self):
|
||||
self.cursor.fetchone.return_value = (HEADERS,)
|
||||
self.cursor.fetchall.return_value = [(4, CELLS)]
|
||||
data, export_id = self.store.export_and_archive("test.xlsx")
|
||||
self.assertTrue(data.startswith(b"PK"))
|
||||
calls = self.cursor.execute.call_args_list
|
||||
self.assertIn("corm_manual_exports", calls[2].args[0])
|
||||
self.assertEqual(calls[3].args[1], ([4],))
|
||||
|
||||
|
||||
class ApiTests(unittest.IsolatedAsyncioTestCase):
|
||||
def setUp(self):
|
||||
self.store = MagicMock()
|
||||
self.store.list_rows.return_value = {"headers": HEADERS, "rows": [{"id": 1, "cells": CELLS, "version": 1}]}
|
||||
self.store.patch_cells.return_value = []
|
||||
self.store.export_and_archive.return_value = (build_xlsx(HEADERS, [CELLS]), "00000000-0000-0000-0000-000000000001")
|
||||
for key, value in (("MANUAL_ORDERS_BACKEND", "postgres"), ("HISTORY_BACKEND", "postgres"), ("_manual_orders", self.store)):
|
||||
mock = patch.object(main, key, value)
|
||||
mock.start()
|
||||
self.addCleanup(mock.stop)
|
||||
google = patch.object(main, "get_manual_worksheet", side_effect=AssertionError("Unexpected Google call"))
|
||||
google.start()
|
||||
self.addCleanup(google.stop)
|
||||
|
||||
async def test_grid_read_patch_and_export_do_not_use_google(self):
|
||||
with patch.object(main, "run_google_io", side_effect=AssertionError("Google unavailable")):
|
||||
self.assertEqual((await request("GET", "/api/manual/orders"))[0], 200)
|
||||
self.assertEqual((await request("PATCH", "/api/manual/orders/cells", {"changes": [{"id": 1, "column": 3, "value": "새 이름", "previous_value": "테스트"}]}))[0], 200)
|
||||
self.assertEqual((await request("POST", "/api/sheet/download_and_clear"))[0], 200)
|
||||
|
||||
async def test_conflicting_autosave_returns_current_values(self):
|
||||
self.store.patch_cells.side_effect = CellConflict([{"id": 1, "column": 3, "value": "최신 이름"}])
|
||||
status, _, body = await request("PATCH", "/api/manual/orders/cells", {"changes": [{"id": 1, "column": 3, "value": "내 이름", "previous_value": "old"}]})
|
||||
self.assertEqual(status, 409)
|
||||
self.assertEqual(json.loads(body)["detail"]["conflicts"][0]["value"], "최신 이름")
|
||||
|
||||
async def test_submission_saves_summary_server_side_and_retains_sheet_layout(self):
|
||||
payload = {"customer_name": "테스트", "phone": "01000000000", "address": "주소", "comment": "요청",
|
||||
"order_type": "normal", "no_lid": False, "total_amount": 3500,
|
||||
"items": [{"code": "TEST-1", "name": "상품", "label": "상품", "quantity": 2, "item_type": "ORDER_SINGLE"}]}
|
||||
status, _, body = await request("POST", "/api/order/submit", payload)
|
||||
self.assertEqual(status, 200)
|
||||
self.assertTrue(json.loads(body)["history_saved"])
|
||||
rows, history = self.store.append.call_args.args
|
||||
self.assertEqual(len(rows[0]), 15)
|
||||
self.assertEqual(rows[0][4:7], ["TEST-1", "상품", 2])
|
||||
self.assertEqual(history["total_amount"], 3500)
|
||||
|
||||
async def test_cancellation_updates_queue_and_history_through_same_store(self):
|
||||
self.assertEqual((await request("DELETE", "/api/manual/history/records/1"))[0], 200)
|
||||
self.store.delete_history.assert_called_once_with(1)
|
||||
|
||||
async def test_legacy_template_uses_sheet_until_migration_and_db_template_uses_grid(self):
|
||||
# Reuse the actual template render path with service authentication.
|
||||
status, _, body = await request("GET", "/")
|
||||
self.assertEqual(status, 200)
|
||||
self.assertIn(b'id="manual-grid-panel"', body)
|
||||
self.assertNotIn(b'id="manual-iframe-container"', body)
|
||||
with patch.object(main, "MANUAL_ORDERS_BACKEND", "google"):
|
||||
self.assertEqual((await request("GET", "/api/manual/orders"))[0], 409)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,77 @@
|
||||
"""Read-only source capture and non-overwriting manual queue migration."""
|
||||
|
||||
import io
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from contextlib import redirect_stdout
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import psycopg2
|
||||
import main
|
||||
import manual_orders_deploy as deployment
|
||||
from manual_orders import HEADERS
|
||||
from settings_migrate import save_snapshot
|
||||
|
||||
|
||||
SOURCE = {"kind": "corm-manual-orders", "headers": HEADERS, "rows": [["2026-10-22"] + [""] * 14]}
|
||||
|
||||
|
||||
class MigrationTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.directory = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.directory.cleanup)
|
||||
self.path = Path(self.directory.name) / "manual-orders-source.json"
|
||||
save_snapshot(self.path, SOURCE, "test")
|
||||
self.store = MagicMock()
|
||||
self.store.list_rows.return_value = {"headers": HEADERS, "rows": [{"id": 1, "cells": SOURCE["rows"][0], "version": 1}]}
|
||||
mocked = patch.object(deployment, "ManualOrderStore", return_value=self.store)
|
||||
mocked.start()
|
||||
self.addCleanup(mocked.stop)
|
||||
|
||||
def test_existing_identical_queue_is_not_reimported(self):
|
||||
with redirect_stdout(io.StringIO()):
|
||||
deployment.migrate(self.directory.name)
|
||||
self.store.import_source.assert_not_called()
|
||||
|
||||
def test_existing_different_queue_is_not_overwritten(self):
|
||||
self.store.list_rows.return_value = {"headers": HEADERS, "rows": []}
|
||||
with self.assertRaises(RuntimeError):
|
||||
deployment.migrate(self.directory.name)
|
||||
self.store.import_source.assert_not_called()
|
||||
|
||||
def test_missing_table_imports_then_validates_every_cell(self):
|
||||
stored = self.store.list_rows.return_value
|
||||
self.store.list_rows.side_effect = [psycopg2.errors.UndefinedTable(), stored]
|
||||
with redirect_stdout(io.StringIO()):
|
||||
deployment.migrate(self.directory.name)
|
||||
self.store.import_source.assert_called_once_with(SOURCE, "manual-order-sheet")
|
||||
|
||||
def test_bad_checksum_never_accesses_database(self):
|
||||
self.path.write_text(self.path.read_text(encoding="utf-8").replace('2026-10-22', '2026-10-23'), encoding="utf-8")
|
||||
with self.assertRaises(ValueError):
|
||||
deployment.migrate(self.directory.name)
|
||||
self.store.list_rows.assert_not_called()
|
||||
|
||||
def test_google_source_keeps_first_sheet_order_and_uses_no_write_helpers(self):
|
||||
client = MagicMock()
|
||||
worksheet = client.open_by_key.return_value.get_worksheet.return_value
|
||||
worksheet.get_all_values.return_value = [HEADERS, ["date"], [], ["other"]]
|
||||
with patch.dict(os.environ, {"MANUAL_ORDERS_BACKEND": "google"}), \
|
||||
patch.object(main, "get_gspread_client", return_value=client):
|
||||
source = deployment.read_source()
|
||||
self.assertEqual(len(source["rows"]), 3)
|
||||
self.assertEqual(source["rows"][1], [""] * 15)
|
||||
client.open_by_key.return_value.get_worksheet.assert_called_once_with(0)
|
||||
worksheet.update.assert_not_called()
|
||||
|
||||
def test_db_source_never_reads_old_google_values(self):
|
||||
with patch.dict(os.environ, {"MANUAL_ORDERS_BACKEND": "postgres"}), \
|
||||
patch.object(main, "get_gspread_client") as google:
|
||||
self.assertEqual(deployment.read_source(), SOURCE)
|
||||
google.assert_not_called()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -75,6 +75,9 @@ class MergeTests(unittest.TestCase):
|
||||
|
||||
class HistoryApiTests(unittest.IsolatedAsyncioTestCase):
|
||||
def setUp(self):
|
||||
manual = patch.object(main, "MANUAL_ORDERS_BACKEND", "google")
|
||||
manual.start()
|
||||
self.addCleanup(manual.stop)
|
||||
self.store = MagicMock()
|
||||
self.store.list_records.return_value = [{**SMS, "id": 42}]
|
||||
self.store.add.return_value = 42
|
||||
|
||||
@@ -121,6 +121,9 @@ class StoreTests(unittest.TestCase):
|
||||
|
||||
class PostgresApiTests(unittest.IsolatedAsyncioTestCase):
|
||||
def setUp(self):
|
||||
manual = patch.object(main, "MANUAL_ORDERS_BACKEND", "google")
|
||||
manual.start()
|
||||
self.addCleanup(manual.stop)
|
||||
histories = patch.object(main, "HISTORY_BACKEND", "google")
|
||||
histories.start()
|
||||
self.addCleanup(histories.stop)
|
||||
|
||||
@@ -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