source: flexoentity/tests/test_sqlite_backend.py@ 753855a

Last change on this file since 753855a was 753855a, checked in by Enrico Schwass <ennoausberlin@…>, 6 weeks ago

add more backends and tests

  • Property mode set to 100644
File size: 836 bytes
Line 
1import sqlite3
2from flexoentity.domain import Domain
3from flexoentity import SQLiteEntityBackend
4
5
6def make_domain(domain_id="PY_ARITHM"):
7 return Domain.with_domain_id(
8 subtype="Domain",
9 domain_id=domain_id,
10 fullname="PYTHON_ARITHMETIC",
11 description="ALL ABOUT ARITHMETIC IN PYTHON",
12 classification="UNCLASSIFIED",
13 )
14
15
16def test_sqlite_roundtrip(tmp_path):
17 db_path = tmp_path / "domains.db"
18 conn = sqlite3.connect(db_path)
19 conn.row_factory = sqlite3.Row
20
21 backend = SQLiteEntityBackend(Domain, conn, table_name="domains")
22
23 dom = make_domain()
24 backend.save(dom)
25
26 loaded = backend.load(dom.flexo_id)
27 assert loaded.to_dict() == dom.to_dict()
28
29 all_loaded = backend.load_all()
30 assert len(all_loaded) == 1
31 assert all_loaded[0].domain_id == "PY_ARITHM"
Note: See TracBrowser for help on using the repository browser.