feat: initialize governed datasources module
This commit is contained in:
31
tests/test_tabular.py
Normal file
31
tests/test_tabular.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from govoplan_core.core.datasources import DatasourceValidationError
|
||||
from govoplan_datasources.backend.tabular import (
|
||||
fingerprint_rows,
|
||||
infer_schema,
|
||||
parse_csv_rows,
|
||||
)
|
||||
|
||||
|
||||
class DatasourceTabularTests(unittest.TestCase):
|
||||
def test_csv_schema_and_fingerprint_are_stable(self) -> None:
|
||||
rows = parse_csv_rows("id;name\n1;Ada\n2;\n", delimiter=";")
|
||||
schema = infer_schema(rows)
|
||||
|
||||
self.assertEqual(["id", "name"], [field.name for field in schema])
|
||||
self.assertTrue(schema[1].nullable)
|
||||
self.assertEqual(
|
||||
fingerprint_rows(rows, schema),
|
||||
fingerprint_rows(rows, schema),
|
||||
)
|
||||
|
||||
def test_csv_requires_headers(self) -> None:
|
||||
with self.assertRaises(DatasourceValidationError):
|
||||
parse_csv_rows("", delimiter=",")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user