Skip to content

Commit

Permalink
Remove unused crud method
Browse files Browse the repository at this point in the history
  • Loading branch information
islean committed Jan 28, 2025
1 parent 2d4eef0 commit 35eac2e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 83 deletions.
18 changes: 0 additions & 18 deletions cg/store/crud/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,24 +678,6 @@ def get_samples_by_customer_and_subject_id(
customer_internal_id=customer_internal_id, subject_id=subject_id
).all()

def get_samples_by_customer_ids_and_subject_id_and_is_tumour(
self, customer_ids: list[int], subject_id: str, is_tumour: bool
) -> list[Sample]:
"""Return a list of samples matching a list of customers with given subject id and is a tumour or not."""
samples = self._get_query(table=Sample)
filter_functions = [
SampleFilter.BY_CUSTOMER_ENTRY_IDS,
SampleFilter.BY_SUBJECT_ID,
SampleFilter.BY_TUMOUR,
]
return apply_sample_filter(
samples=samples,
customer_entry_ids=customer_ids,
subject_id=subject_id,
is_tumour=is_tumour,
filter_functions=filter_functions,
).all()

def get_samples_by_any_id(self, **identifiers: dict) -> Query:
"""Return a sample query filtered by the given names and values of Sample attributes."""
samples: Query = self._get_query(table=Sample).order_by(Sample.internal_id.desc())
Expand Down
65 changes: 0 additions & 65 deletions tests/store/crud/read/test_read_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,71 +115,6 @@ def test_get_samples_by_subject_id(
assert samples and len(samples) == 2


def test_get_samples_by_customer_id_list_and_subject_id_and_is_tumour(
store_with_samples_customer_id_and_subject_id_and_tumour_status: Store,
customer_ids: list[int] = [1, 2],
subject_id: str = "test_subject",
is_tumour: bool = True,
):
"""Test that samples can be fetched by customer ID, subject ID, and tumour status."""
# GIVEN a database with four samples, two with customer ID 1 and two with customer ID 2

# ASSERT that there are customers with the given customer IDs
for customer_id in customer_ids:
assert store_with_samples_customer_id_and_subject_id_and_tumour_status.get_customer_by_internal_id(
customer_internal_id=str(customer_id)
)

# WHEN fetching the samples by customer ID list, subject ID, and tumour status
samples = store_with_samples_customer_id_and_subject_id_and_tumour_status.get_samples_by_customer_ids_and_subject_id_and_is_tumour(
customer_ids=customer_ids, subject_id=subject_id, is_tumour=is_tumour
)

# THEN two samples should be returned, one for each customer ID, with the specified subject ID and tumour status
assert isinstance(samples, list)
assert len(samples) == 2

for sample in samples:
assert isinstance(sample, Sample)

for customer_id, sample in zip(customer_ids, samples):
assert sample.customer_id == customer_id
assert sample.subject_id == subject_id
assert sample.is_tumour == is_tumour


def test_get_samples_by_customer_id_list_and_subject_id_and_is_tumour_with_non_existing_customer_id(
store_with_samples_customer_id_and_subject_id_and_tumour_status: Store,
):
"""Test that no samples are returned when filtering on non-existing customer ID."""
# GIVEN a database with four samples, two with customer ID 1 and two with customer ID 2

# ASSERT that there are no customers with the given customer IDs
customer_ids = [1, 2, 3]
for customer_id in customer_ids:
if customer_id == 3:
assert (
store_with_samples_customer_id_and_subject_id_and_tumour_status.get_customer_by_internal_id(
customer_internal_id=str(customer_id)
)
is None
)
else:
assert store_with_samples_customer_id_and_subject_id_and_tumour_status.get_customer_by_internal_id(
customer_internal_id=str(customer_id)
)

# WHEN fetching the samples by customer ID list, subject ID, and tumour status
non_existing_customer_id = [3]
samples = store_with_samples_customer_id_and_subject_id_and_tumour_status.get_samples_by_customer_ids_and_subject_id_and_is_tumour(
customer_ids=non_existing_customer_id, subject_id="test_subject", is_tumour=True
)

# THEN no samples should be returned
assert isinstance(samples, list)
assert len(samples) == 0


def test_get_sample_by_name(store_with_samples_that_have_names: Store, name="test_sample_1"):
"""Test that samples can be fetched by name."""
# GIVEN a database with two samples of which one has a name
Expand Down

0 comments on commit 35eac2e

Please sign in to comment.