Skip to content

Commit

Permalink
Add phenotype inventory test to see if it fails
Browse files Browse the repository at this point in the history
This new test tests a possibly related bug (see PR #675)
that we couldn't get to fail in CI, possibly due to different
collation settings. If it fails here, adding the charset/collation
setting for the test database should make it fail in this branch.
  • Loading branch information
amstilp committed Jul 30, 2024
1 parent 13d6256 commit 9e6e8c3
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions primed/primed_anvil/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,3 +789,74 @@ def test_multiple_workspace_types_separate_studies(self):
self.assertEqual(res["test-bp-cdsa/test-ws-cdsa"], "TEST 2")
self.assertIn("test-bp-open/test-ws-open", res)
self.assertEqual(res["test-bp-open/test-ws-open"], "TEST 3")

def test_non_consecutive_grouping(self):
"""Studies are grouped even if workspaces are listed non-consecutively."""
# This replicates an issue seen in prod:
# 1) there are multiple workspaces for the same set of studies
# 2) objects are created in a specific order with specific alphabetizing.
# The difference in behavior between sqlite and mariadb is likely due to different ordering
# when the queryset results are returned, so debugging is tricky.
study_1 = StudyFactory.create(short_name="TEST_2")
study_2 = StudyFactory.create(short_name="TEST_1")
study_accession_1 = dbGaPStudyAccessionFactory.create(dbgap_phs=964, studies=[study_1, study_2])
study_accession_2 = dbGaPStudyAccessionFactory.create(dbgap_phs=286, studies=[study_2])
# Two workspaces associated with study_accession_1 (with two studies)
workspace_1_a = dbGaPWorkspaceFactory.create(
workspace__billing_project__name="test-b",
workspace__name="test-a-b_c3",
dbgap_study_accession=study_accession_1,
)
WorkspaceGroupSharingFactory.create(workspace=workspace_1_a.workspace, group=self.primed_all_group)
workspace_2_a = dbGaPWorkspaceFactory.create(
workspace__billing_project__name="test-a",
workspace__name="test-a_c3",
dbgap_study_accession=study_accession_2,
)
WorkspaceGroupSharingFactory.create(workspace=workspace_2_a.workspace, group=self.primed_all_group)
workspace_2_b = dbGaPWorkspaceFactory.create(
workspace__billing_project__name="test-a",
workspace__name="test-a_c4",
dbgap_study_accession=study_accession_2,
)
WorkspaceGroupSharingFactory.create(workspace=workspace_2_b.workspace, group=self.primed_all_group)
workspace_2_c = dbGaPWorkspaceFactory.create(
workspace__billing_project__name="test-a",
workspace__name="test-a_c2",
dbgap_study_accession=study_accession_2,
)
WorkspaceGroupSharingFactory.create(workspace=workspace_2_c.workspace, group=self.primed_all_group)
workspace_2_d = dbGaPWorkspaceFactory.create(
workspace__billing_project__name="test-a",
workspace__name="test-a_c1",
dbgap_study_accession=study_accession_2,
)
WorkspaceGroupSharingFactory.create(workspace=workspace_2_d.workspace, group=self.primed_all_group)
workspace_1_b = dbGaPWorkspaceFactory.create(
workspace__billing_project__name="test-b",
workspace__name="test-a-b_c4",
dbgap_study_accession=study_accession_1,
)
WorkspaceGroupSharingFactory.create(workspace=workspace_1_b.workspace, group=self.primed_all_group)
workspace_1_c = dbGaPWorkspaceFactory.create(
workspace__billing_project__name="test-b",
workspace__name="test-a-b_c1",
dbgap_study_accession=study_accession_1,
)
WorkspaceGroupSharingFactory.create(workspace=workspace_1_c.workspace, group=self.primed_all_group)
workspace_1_d = dbGaPWorkspaceFactory.create(
workspace__billing_project__name="test-b",
workspace__name="test-a-b_c2",
dbgap_study_accession=study_accession_1,
)
WorkspaceGroupSharingFactory.create(workspace=workspace_1_d.workspace, group=self.primed_all_group)
res = helpers.get_workspaces_for_phenotype_inventory()
self.assertEqual(len(res), 8)
self.assertEqual(res["test-b/test-a-b_c1"], "TEST_1, TEST_2")
self.assertEqual(res["test-b/test-a-b_c2"], "TEST_1, TEST_2")
self.assertEqual(res["test-b/test-a-b_c3"], "TEST_1, TEST_2")
self.assertEqual(res["test-b/test-a-b_c4"], "TEST_1, TEST_2")
self.assertEqual(res["test-a/test-a_c1"], "TEST_1")
self.assertEqual(res["test-a/test-a_c2"], "TEST_1")
self.assertEqual(res["test-a/test-a_c3"], "TEST_1")
self.assertEqual(res["test-a/test-a_c4"], "TEST_1")

0 comments on commit 9e6e8c3

Please sign in to comment.