unify_backends
| Rev | Line | |
|---|
| [753855a] | 1 | import sqlite3
|
|---|
| 2 | from flexoentity.domain import Domain
|
|---|
| 3 | from flexoentity import SQLiteEntityBackend
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| [3389960] | 6 | def test_sqlite_roundtrip(tmp_path, sample_domain):
|
|---|
| [753855a] | 7 | db_path = tmp_path / "domains.db"
|
|---|
| 8 | conn = sqlite3.connect(db_path)
|
|---|
| 9 | conn.row_factory = sqlite3.Row
|
|---|
| 10 |
|
|---|
| 11 | backend = SQLiteEntityBackend(Domain, conn, table_name="domains")
|
|---|
| 12 |
|
|---|
| [3389960] | 13 | backend.save(sample_domain.to_dict())
|
|---|
| [753855a] | 14 |
|
|---|
| [3389960] | 15 | loaded = backend.load(sample_domain.flexo_id)
|
|---|
| 16 | assert loaded == sample_domain.to_dict()
|
|---|
| [753855a] | 17 |
|
|---|
| 18 | all_loaded = backend.load_all()
|
|---|
| 19 | assert len(all_loaded) == 1
|
|---|
| [3389960] | 20 | assert Domain.from_dict(all_loaded[0]).domain_id == "PY_ARITHM"
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.