Skip to content

Commit

Permalink
Merge pull request #230 from nerdstrike/can_test_data_factory
Browse files Browse the repository at this point in the history
Remove the now unused test data factory fixture.
  • Loading branch information
mgcam authored Jun 14, 2024
2 parents 6516d9b + a467f64 commit efff421
Showing 1 changed file with 0 additions and 101 deletions.
101 changes: 0 additions & 101 deletions tests/fixtures/inbox_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,104 +97,3 @@ def inbox_data(mlwhdb_test_session):
mlwhdb_test_session.commit()

yield True


@pytest.fixture()
def test_data_factory(mlwhdb_test_session, qcdb_test_session):
def setup_data(desired_wells):
# Setup dicts and "filler" data

library_qc_type = QcType(
qc_type="library", description="Sample/library evaluation"
)
seq_qc_type = QcType(
qc_type="sequencing", description="Sequencing process evaluation"
)

run_name_attr = SubProductAttr(
attr_name="run_name", description="PacBio run name."
)
well_label_attr = SubProductAttr(
attr_name="well_label", description="PacBio well label"
)
seq_platform = SeqPlatform(name="PacBio", description="Pacific Biosciences.")
user = User(username="[email protected]")
other_user = User(username="[email protected]")
states = ["Passed", "Failed", "Claimed", "On hold", "Aborted"]
state_dicts = {}

for state in states:
outcome = None
if state == "Passed":
outcome = True
elif state == "Failed":
outcome = False
state_dicts[state] = QcStateDict(state=state, outcome=outcome)

qcdb_test_session.add_all(state_dicts.values())
qcdb_test_session.add_all(
[
library_qc_type,
seq_qc_type,
run_name_attr,
well_label_attr,
seq_platform,
user,
other_user,
]
)

# Start adding the PacBioRunWellMetrics and QcState rows.
for run_name, wells in desired_wells.items():
for well_label, state in wells.items():

pbe = PacBioEntity(run_name=run_name, well_label=well_label)
id = pbe.hash_product_id()

run_metrics = PacBioRunWellMetrics(
pac_bio_run_name=run_name,
well_label=well_label,
id_pac_bio_product=id,
instrument_type="PacBio",
polymerase_num_reads=1337,
ccs_execution_mode="None",
well_status="Complete",
run_start=datetime.now() - timedelta(days=3),
run_complete=datetime.now() - timedelta(days=1),
well_start=datetime.now() - timedelta(days=2),
well_complete=datetime.now() - timedelta(days=1),
)
mlwhdb_test_session.add(run_metrics)

if state is not None:

qc_state = QcState(
created_by="me",
is_preliminary=state in ["On hold", "Claimed"],
qc_state_dict=state_dicts[state],
qc_type=seq_qc_type,
seq_product=SeqProduct(
id_product=id,
seq_platform=seq_platform,
sub_products=[
SubProduct(
sub_product_attr=run_name_attr,
sub_product_attr_=well_label_attr,
value_attr_one=run_name,
value_attr_two=well_label,
properties_digest=id,
),
],
),
user=user,
)
qcdb_test_session.add(qc_state)
# Feed back to fixture use
desired_wells[run_name][well_label] = qc_state

qcdb_test_session.commit()
mlwhdb_test_session.commit()

return desired_wells

yield setup_data

0 comments on commit efff421

Please sign in to comment.