Skip to content

Commit

Permalink
Improve tests for data summary view
Browse files Browse the repository at this point in the history
Test that dbGaP workspaces and open access workspaces are included in
separate tests. Add dbgap to the names of the tests in the helper
function tests.
  • Loading branch information
amstilp committed Apr 5, 2024
1 parent ce60b2a commit c207150
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
14 changes: 7 additions & 7 deletions primed/primed_anvil/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def test_one_open_access_workspace_one_study_not_shared_no_available_data(self):
self.assertIn("Foo", res[0])
self.assertEqual(res[0]["Foo"], False)

def test_one_workspace_one_study_not_shared_with_one_available_data(self):
def test_one_dbgap_workspace_one_study_not_shared_with_one_available_data(self):
available_data = AvailableDataFactory.create(name="Foo")
study = StudyFactory.create(short_name="TEST")
dbgap_workspace = dbGaPWorkspaceFactory.create(
Expand All @@ -79,7 +79,7 @@ def test_one_workspace_one_study_not_shared_with_one_available_data(self):
self.assertIn("Foo", res[0])
self.assertEqual(res[0]["Foo"], True)

def test_one_workspace_one_study_not_shared_with_two_available_data(self):
def test_one_dbgap_workspace_one_study_not_shared_with_two_available_data(self):
available_data_1 = AvailableDataFactory.create(name="Foo")
available_data_2 = AvailableDataFactory.create(name="Bar")
study = StudyFactory.create(short_name="TEST")
Expand All @@ -101,7 +101,7 @@ def test_one_workspace_one_study_not_shared_with_two_available_data(self):
self.assertIn("Foo", res[0])
self.assertEqual(res[0]["Foo"], True)

def test_one_workspace_two_studies_not_shared_no_available_data(self):
def test_one_dbgap_workspace_two_studies_not_shared_no_available_data(self):
AvailableDataFactory.create(name="Foo")
study_1 = StudyFactory.create(short_name="TEST")
study_2 = StudyFactory.create(short_name="Other")
Expand All @@ -119,7 +119,7 @@ def test_one_workspace_two_studies_not_shared_no_available_data(self):
self.assertIn("Foo", res[0])
self.assertEqual(res[0]["Foo"], False)

def test_one_workspace_one_study_shared_no_available_data(self):
def test_one_dbgap_workspace_one_study_shared_no_available_data(self):
AvailableDataFactory.create(name="Foo")
study = StudyFactory.create(short_name="TEST")
dbgap_workspace = dbGaPWorkspaceFactory.create(
Expand All @@ -141,7 +141,7 @@ def test_one_workspace_one_study_shared_no_available_data(self):
self.assertIn("Foo", res[0])
self.assertEqual(res[0]["Foo"], False)

def test_two_workspaces_one_study(self):
def test_two_dbgap_workspaces_one_study(self):
AvailableDataFactory.create(name="Foo")
study = StudyFactory.create(short_name="TEST")
dbGaPWorkspaceFactory.create(dbgap_study_accession__studies=[study])
Expand All @@ -159,7 +159,7 @@ def test_two_workspaces_one_study(self):
self.assertIn("Foo", res[0])
self.assertEqual(res[0]["Foo"], False)

def test_two_workspaces_one_study_one_shared(self):
def test_two_dbgap_workspaces_one_study_one_shared(self):
available_data_1 = AvailableDataFactory.create(name="Foo")
available_data_2 = AvailableDataFactory.create(name="Bar")
study = StudyFactory.create(short_name="TEST")
Expand Down Expand Up @@ -197,7 +197,7 @@ def test_two_workspaces_one_study_one_shared(self):
res,
)

def test_two_workspaces_multiple_studies(self):
def test_two_dbgap_workspaces_multiple_studies(self):
AvailableDataFactory.create(name="Foo")
study_1 = StudyFactory.create(short_name="TEST")
study_2 = StudyFactory.create(short_name="Other")
Expand Down
22 changes: 22 additions & 0 deletions primed/primed_anvil/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,3 +1239,25 @@ def test_table_rows(self):
response = self.client.get(self.get_url())
self.assertIn("summary_table", response.context_data)
self.assertEqual(len(response.context_data["summary_table"].rows), 2)

def test_includes_open_access_workspaces(self):
"""Open access workspaces are included in the table."""
study = StudyFactory.create()
open_workspace = OpenAccessWorkspaceFactory.create()
open_workspace.studies.add(study)
open_workspace.available_data.add(self.available_data)
self.client.force_login(self.user)
response = self.client.get(self.get_url())
self.assertIn("summary_table", response.context_data)
self.assertEqual(len(response.context_data["summary_table"].rows), 1)

def test_includes_dbgap_workspaces(self):
"""dbGaP workspaces are included in the table."""
# One open access workspace with one study, with one available data type.
# One dbGaP workspae with two studies.
study = StudyFactory.create()
dbGaPWorkspaceFactory.create(dbgap_study_accession__studies=[study])
self.client.force_login(self.user)
response = self.client.get(self.get_url())
self.assertIn("summary_table", response.context_data)
self.assertEqual(len(response.context_data["summary_table"].rows), 1)

0 comments on commit c207150

Please sign in to comment.