- Delete 4 empty, unreferenced orphan scripts in dev/scripts/ (find_databricks_workspace, scrape_bls_data, generate_bls_express, test_databricks_connection). - Remove the unconditionally-skipped TestFixFields.test_runs in tests/zot/test_ops.py — fix_fields is already exercised end-to-end by test_ops_deep.py::test_fix_fields_remap_and_delete (which builds the itemTypeFieldsCombined view the stub said it needed). - Remove the empty .github/workflows/ orphan left from the Gitea move (CI lives entirely in .gitea/workflows/). - Drop two dead locals in dev/scripts (F841): an unused authors_section loop and a `tags` assignment immediately overwritten by fresh_tags. - docs/docs/intro.md listed only 9 of 17 modules — sync the packages table and src/ tree with the actual module set.
52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
"""Tests for zot.ops — Zotero maintenance operations."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sqlite3
|
|
|
|
import pytest
|
|
|
|
from tests.zot.test_db import ZOTERO_SCHEMA, _seed_schema_maps
|
|
from zot.db import TYPE_MAP, Db
|
|
|
|
|
|
@pytest.fixture()
|
|
def zot_path(tmp_path):
|
|
path = str(tmp_path / "zotero.sqlite")
|
|
con = sqlite3.connect(path)
|
|
con.executescript(ZOTERO_SCHEMA)
|
|
_seed_schema_maps(con)
|
|
con.commit()
|
|
con.close()
|
|
return path
|
|
|
|
|
|
class TestDumpSchema:
|
|
def test_dumps_types(self, zot_path):
|
|
from zot.ops import dump_schema
|
|
|
|
result = dump_schema(zot_path)
|
|
assert "TYPE_MAP" in result
|
|
assert "FIELD_MAP" in result
|
|
assert "CREATOR_TYPES" in result
|
|
assert "attachment" in result["TYPE_MAP"]
|
|
|
|
|
|
class TestFixDates:
|
|
def test_runs(self, zot_path):
|
|
from zot.ops import fix_dates
|
|
|
|
with Db(zot_path) as db:
|
|
item_id = db.create_item(TYPE_MAP["document"])
|
|
db.set_fields(item_id, {"date": "2023-07-15"})
|
|
result = fix_dates(zot_path)
|
|
assert isinstance(result, dict)
|
|
|
|
|
|
class TestFixKeys:
|
|
def test_runs(self, zot_path):
|
|
from zot.ops import fix_keys
|
|
|
|
result = fix_keys(zot_path)
|
|
assert isinstance(result, dict)
|