seamm_datastore.tests package

Submodules

seamm_datastore.tests.conftest module

Fixtures for testing

seamm_datastore.tests.conftest.admin_connection(connection)[source]
seamm_datastore.tests.conftest.connection()[source]
seamm_datastore.tests.conftest.filled_db(connection)[source]
seamm_datastore.tests.conftest.session()[source]

seamm_datastore.tests.test_build module

Tests for building/importing datastore

seamm_datastore.tests.test_build.test_build(connection)[source]
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_add_job(connection)[source]
seamm_datastore.tests.test_create.test_create_user(connection)[source]
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_from_file(connection)[source]
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_parse(connection)[source]
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.

seamm_datastore.tests.test_create.test_job_create_shared_flowchart_reuses_row(connection)[source]

Two jobs that use the same flowchart file must share one Flowchart row.

seamm_datastore.tests.test_create.test_project_create(connection)[source]

Test the create method of the project object

seamm_datastore.tests.test_create.test_project_create_group(connection)[source]
seamm_datastore.tests.test_create.test_project_exists(connection)[source]
seamm_datastore.tests.test_create.test_project_no_user(connection)[source]

seamm_datastore.tests.test_errors module

seamm_datastore.tests.test_methods module

API Tests

seamm_datastore.tests.test_methods.test_get_queries(filled_db, resource, description, title, offset, limit, sort, order, num_records, first_id)[source]
seamm_datastore.tests.test_methods.test_job_update(filled_db)[source]
seamm_datastore.tests.test_methods.test_job_update_error(filled_db)[source]

seamm_datastore.tests.test_seamm_datastore module

Unit and regression test for the seamm_datastore package.

seamm_datastore.tests.test_seamm_datastore.test_connected(admin_connection)[source]
seamm_datastore.tests.test_seamm_datastore.test_connection_logout(connection)[source]

Module contents

Empty init file in case you choose a package besides PyTest such as Nose which may look for such a file