Expand governed Dataflow editor and node library
This commit is contained in:
43
tests/test_schemas.py
Normal file
43
tests/test_schemas.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from govoplan_dataflow.backend.schemas import TabularSnapshotCreateRequest
|
||||
|
||||
|
||||
class DataflowSchemaTests(unittest.TestCase):
|
||||
def test_snapshot_request_requires_the_selected_format_payload(self) -> None:
|
||||
json_request = TabularSnapshotCreateRequest(
|
||||
name="Monthly cases",
|
||||
source_name="monthly_cases",
|
||||
format="json",
|
||||
rows=[{"case_id": "0012"}],
|
||||
)
|
||||
csv_request = TabularSnapshotCreateRequest(
|
||||
name="Monthly cases",
|
||||
source_name="monthly_cases_csv",
|
||||
format="csv",
|
||||
csv_text="case_id;amount\n0012;7.5\n",
|
||||
delimiter=";",
|
||||
)
|
||||
|
||||
self.assertEqual([{"case_id": "0012"}], json_request.rows)
|
||||
self.assertEqual(";", csv_request.delimiter)
|
||||
with self.assertRaises(ValueError):
|
||||
TabularSnapshotCreateRequest(
|
||||
name="Missing rows",
|
||||
source_name="missing_rows",
|
||||
format="json",
|
||||
)
|
||||
with self.assertRaises(ValueError):
|
||||
TabularSnapshotCreateRequest(
|
||||
name="Ambiguous",
|
||||
source_name="ambiguous",
|
||||
format="csv",
|
||||
rows=[],
|
||||
csv_text="id\n1\n",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user