seamm_datastore.tests package
Submodules
seamm_datastore.tests.conftest module
Fixtures for testing
seamm_datastore.tests.test_build module
Tests for building/importing datastore
- seamm_datastore.tests.test_build.test_import_datastore_duplicate_project_name_recovers(connection, tmp_path)[source]
A job_data.json listing the same project twice (a real case seen in production – e.g. from a job submitted with a malformed project list) used to crash the whole import scan with an IntegrityError (“UNIQUE constraint failed: job_project.job, job_project.project”), raised from session.commit() in import_datastore. That commit sat in an else: clause the surrounding try/except couldn’t reach, so the failure propagated out of import_datastore entirely – aborting the scan and leaving every job after the bad one (in directory-listing order) unimported too, every time the dashboard started.
Fixed two ways: Job.create() now dedupes project_names before it’s used to populate any relationship (the actual root cause – assigning the same related row twice to a SQLAlchemy many-to-many collection is what raises the IntegrityError), and import_datastore’s per-job add()/commit() is now inside the try/except with a rollback, so even an unrelated per-job failure can no longer take down the whole scan.
seamm_datastore.tests.test_create module
Test the create functions on the SQLAlchemy models
- seamm_datastore.tests.test_create.test_flowchart_duplicate_hash_raises(connection)[source]
Directly re-creating the same flowchart via create is still an error.
- seamm_datastore.tests.test_create.test_flowchart_get_or_create_concurrent_race(tmp_path)[source]
A get-or-create that loses a race to another job’s commit must fall back to the winner’s row instead of crashing.
Reproduces https://github.com/molssi-seamm/seamm_datastore/issues/37 : a job array submitting several jobs that share a flowchart which isn’t registered yet. Each sees “no flowchart with this hash” and races to insert it; before this fix, every insert after the first left a duplicate row, and every later lookup by hash crashed with MultipleResultsFound.
The race is reproduced deterministically – a competing row for the same hash is committed by a second, raw connection to the same database file, timed to land in the window between our own lookup and our own insert – rather than depending on real thread scheduling, which is flaky against SQLite’s single-writer locking.
- seamm_datastore.tests.test_create.test_flowchart_sha256_strict_unique_constraint(connection)[source]
The DB itself must reject a second flowcharts row for the same hash.
This is the schema-level half of the fix for https://github.com/molssi-seamm/seamm_datastore/issues/37 : previously nothing stopped two rows from sharing a
sha256_strict, which is what let the concurrent-submission race described in the issue corrupt the table in the first place.
Two jobs that use the same flowchart file must share one Flowchart row.
seamm_datastore.tests.test_errors module
seamm_datastore.tests.test_methods module
API Tests
seamm_datastore.tests.test_seamm_datastore module
Unit and regression test for the seamm_datastore package.
Module contents
Empty init file in case you choose a package besides PyTest such as Nose which may look for such a file