Skip to content

Commit

Permalink
Use dict. values() method where only values are used
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcam committed May 24, 2024
1 parent 8b1895b commit a469b53
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tests/endpoints/test_dump_qc_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,29 @@ def test_get_qc(test_client: TestClient, load_data4well_retrieval):
assert response.status_code == 200
response_data = response.json()
assert len(response_data) == 18
assert sum([len(l) for (id, l) in response_data.items()]) == 34
assert sum([len(l) for l in response_data.values()]) == 34

response = test_client.get(
f"/products/qc?weeks={num_weeks}&final=false&seq_level=no"
)
assert response.status_code == 200
response_data = response.json()
assert len(response_data) == 18
assert sum([len(l) for (id, l) in response_data.items()]) == 34
assert sum([len(l) for l in response_data.values()]) == 34

response = test_client.get(f"/products/qc?weeks={num_weeks}&final=true")
assert response.status_code == 200
response_data = response.json()
assert len(response_data) == 4
assert sum([len(l) for (id, l) in response_data.items()]) == 8
assert sum([len(l) for l in response_data.values()]) == 8

response = test_client.get(
f"/products/qc?weeks={num_weeks}&final=True&seq_level=yes"
)
assert response.status_code == 200
response_data = response.json()
assert len(response_data) == 4
assert sum([len(l) for (id, l) in response_data.items()]) == 4
assert sum([len(l) for l in response_data.values()]) == 4
product_id = "5e91b9246b30c2df4e9f2a2313ce097e93493b0a822e9d9338e32df5d58db585"
assert product_id in response_data
qc_state = response_data[product_id][0]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_qc_state_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ def test_bulk_retrieval(qcdb_test_session, load_data4well_retrieval):
min_num_weeks = int(min_interval.days / 7 - 1)

assert min_num_weeks > 2
# Set the look-back number of weeks to teh period with no records.
# Set the look-back number of weeks to the period with no records.
qc_states_dict = get_qc_states(qcdb_test_session, num_weeks=(min_num_weeks - 1))
assert len(qc_states_dict) == 0

# Retrieve all available QC states.
qc_states_dict = get_qc_states(qcdb_test_session, num_weeks=max_num_weeks)
# Test total number of QcState objects.
assert sum([len(l) for (id, l) in qc_states_dict.items()]) == len(qc_states)
assert sum([len(l) for l in qc_states_dict.values()]) == len(qc_states)
# Test number of items in the dictionary.
assert len(qc_states_dict) == len(
{qc_state.id_seq_product: 1 for qc_state in qc_states}
Expand All @@ -106,7 +106,7 @@ def test_bulk_retrieval(qcdb_test_session, load_data4well_retrieval):
qc_states_dict = get_qc_states(
qcdb_test_session, num_weeks=max_num_weeks, final_only=True
)
assert sum([len(l) for (id, l) in qc_states_dict.items()]) == len(
assert sum([len(l) for l in qc_states_dict.values()]) == len(
[qc_state for qc_state in qc_states if qc_state.is_preliminary == 0]
)
assert {id: len(l) for (id, l) in qc_states_dict.items()} == {
Expand Down

0 comments on commit a469b53

Please sign in to comment.