Skip to content

Commit

Permalink
Merge pull request wtsi-npg#200 from kjsanger/chore/test-maintenance
Browse files Browse the repository at this point in the history
Improve test layout and consistency
  • Loading branch information
kjsanger authored Oct 3, 2023
2 parents c32d41e + adf19e3 commit eb856f0
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 87 deletions.
34 changes: 25 additions & 9 deletions tests/test_illumina.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def test_updates_absent_metadata(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345.cram"

obj = DataObject(path)
expected_avus = [
AVU(TrackedSample.COMMON_NAME, "common_name1"),
Expand Down Expand Up @@ -66,8 +67,9 @@ def test_updates_absent_metadata(
def test_updates_present_metadata(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345.cram"
zone = "testZone"
path = illumina_synthetic_irods / "12345/12345.cram"

obj = DataObject(path)
expected_avus = [
AVU(TrackedSample.COMMON_NAME, "common_name1"),
Expand Down Expand Up @@ -101,6 +103,7 @@ def test_updates_changed_metadata(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345.cram"

obj = DataObject(path)
old_avus = [AVU(TrackedSample.NAME, "sample 99"), AVU(TrackedStudy.ID, "9999")]
obj.add_metadata(*old_avus)
Expand Down Expand Up @@ -135,6 +138,7 @@ def test_updates_multiple_metadata(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345.cram"

obj = DataObject(path)
old_avus = [
AVU(TrackedSample.NAME, "sample 99"),
Expand Down Expand Up @@ -164,6 +168,7 @@ def test_updates_absent_metadata_mx(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345#1.cram"

obj = DataObject(path)
expected_avus = [
AVU(TrackedSample.COMMON_NAME, "common_name1"),
Expand Down Expand Up @@ -197,6 +202,7 @@ def test_updates_control_metadata_mx(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345#888.cram"

obj = DataObject(path)

with pytest.raises(ValueError):
Expand All @@ -212,6 +218,7 @@ def test_updates_absent_metadata_mx_tag0(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345#0.cram"

obj = DataObject(path)
expected_avus = [
AVU(TrackedSample.COMMON_NAME, "common_name1"),
Expand Down Expand Up @@ -248,6 +255,7 @@ def test_updates_control_metadata_mx_tag0(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345#0.cram"

obj = DataObject(path)
expected_avus = [
AVU(TrackedSample.COMMON_NAME, "common_name1"),
Expand Down Expand Up @@ -287,8 +295,9 @@ class TestIlluminaPermissionsUpdate:
def test_updates_absent_study_permissions(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345.cram"
zone = "testZone"
path = illumina_synthetic_irods / "12345/12345.cram"

obj = DataObject(path)

assert obj.permissions() == [AC("irods", perm=Permission.OWN, zone=zone)]
Expand All @@ -306,8 +315,9 @@ def test_updates_absent_study_permissions(
def test_updates_present_study_permissions(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345.cram"
zone = "testZone"
path = illumina_synthetic_irods / "12345/12345.cram"

obj = DataObject(path)

expected_metadata = [
Expand Down Expand Up @@ -340,8 +350,9 @@ def test_updates_present_study_permissions(
def test_updates_changed_study_permissions(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345.cram"
zone = "testZone"
path = illumina_synthetic_irods / "12345/12345.cram"

obj = DataObject(path)
obj.add_permissions(AC("ss_1000", Permission.READ, zone=zone))
old_permissions = [
Expand All @@ -365,8 +376,9 @@ def test_updates_changed_study_permissions(
def test_updates_human_permissions_mx(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345#1_human.cram"
zone = "testZone"
path = illumina_synthetic_irods / "12345/12345#1_human.cram"

obj = DataObject(path)
expected_acl = [
AC("irods", perm=Permission.OWN, zone=zone),
Expand All @@ -386,8 +398,9 @@ def test_updates_human_permissions_mx(
def test_updates_xahuman_permissions_mx(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345#1_xahuman.cram"
zone = "testZone"
path = illumina_synthetic_irods / "12345/12345#1_xahuman.cram"

obj = DataObject(path)
expected_acl = [
AC("irods", perm=Permission.OWN, zone=zone),
Expand All @@ -407,8 +420,9 @@ def test_updates_xahuman_permissions_mx(
def test_multiple_study_permissions_mx(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345#2.cram"
zone = "testZone"
path = illumina_synthetic_irods / "12345/12345#2.cram"

obj = DataObject(path)
obj.add_permissions(
AC("ss_4000", Permission.READ, zone=zone),
Expand All @@ -426,8 +440,9 @@ def test_multiple_study_permissions_mx(
def test_retains_consent_withdrawn(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345.cram"
zone = "testZone"
path = illumina_synthetic_irods / "12345/12345.cram"

obj = DataObject(path)

assert ensure_consent_withdrawn(obj)
Expand All @@ -443,8 +458,9 @@ def test_retains_consent_withdrawn(
def test_updates_human_permissions_mx(
self, illumina_synthetic_irods, illumina_synthetic_mlwh
):
path = illumina_synthetic_irods / "12345/12345#1_human.cram"
zone = "testZone"
path = illumina_synthetic_irods / "12345/12345#1_human.cram"

obj = DataObject(path)

assert ensure_consent_withdrawn(obj)
Expand Down
Loading

0 comments on commit eb856f0

Please sign in to comment.