Skip to content

Commit

Permalink
Update view tests for new REPLACED status
Browse files Browse the repository at this point in the history
  • Loading branch information
amstilp committed Jan 19, 2024
1 parent 948b3fd commit f0e4484
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
29 changes: 29 additions & 0 deletions primed/cdsa/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,10 @@ def test_only_sets_active_signed_agreements_to_lapsed(self):
version__major_version=instance,
status=models.SignedAgreement.StatusChoices.LAPSED,
)
replaced_agreement = factories.SignedAgreementFactory.create(
version__major_version=instance,
status=models.SignedAgreement.StatusChoices.REPLACED,
)
self.client.force_login(self.user)
response = self.client.post(self.get_url(instance.version), {})
self.assertEqual(response.status_code, 302)
Expand All @@ -559,6 +563,10 @@ def test_only_sets_active_signed_agreements_to_lapsed(self):
self.assertEqual(
withdrawn_agreement.status, models.SignedAgreement.StatusChoices.WITHDRAWN
)
replaced_agreement.refresh_from_db()
self.assertEqual(
replaced_agreement.status, models.SignedAgreement.StatusChoices.REPLACED
)

def test_only_sets_associated_signed_agreements_to_lapsed(self):
"""Does not set SignedAgreements associated with a different version to LAPSED."""
Expand Down Expand Up @@ -5293,6 +5301,9 @@ def test_only_includes_active_agreements(self):
withdrawn_agreement = factories.MemberAgreementFactory.create(
signed_agreement__status=models.SignedAgreement.StatusChoices.WITHDRAWN
)
replaced_agreement = factories.MemberAgreementFactory.create(
signed_agreement__status=models.SignedAgreement.StatusChoices.REPLACED
)
self.client.force_login(self.user)
response = self.client.get(self.get_url())
self.assertIn("table", response.context_data)
Expand All @@ -5301,6 +5312,7 @@ def test_only_includes_active_agreements(self):
self.assertIn(active_agreement.signed_agreement, table.data)
self.assertNotIn(lapsed_agreement.signed_agreement, table.data)
self.assertNotIn(withdrawn_agreement.signed_agreement, table.data)
self.assertNotIn(replaced_agreement.signed_agreement, table.data)


class SignedAgreementAuditTest(TestCase):
Expand Down Expand Up @@ -5758,6 +5770,9 @@ def test_only_includes_active_agreements(self):
withdrawn_agreement = factories.DataAffiliateAgreementFactory.create(
signed_agreement__status=models.SignedAgreement.StatusChoices.WITHDRAWN
)
replaced_agreement = factories.DataAffiliateAgreementFactory.create(
signed_agreement__status=models.SignedAgreement.StatusChoices.REPLACED
)
self.client.force_login(self.user)
response = self.client.get(self.get_url())
self.assertIn("table", response.context_data)
Expand All @@ -5766,6 +5781,7 @@ def test_only_includes_active_agreements(self):
self.assertIn(active_agreement, table.data)
self.assertNotIn(lapsed_agreement, table.data)
self.assertNotIn(withdrawn_agreement, table.data)
self.assertNotIn(replaced_agreement, table.data)


class UserAccessRecordsList(TestCase):
Expand Down Expand Up @@ -5943,6 +5959,12 @@ def test_only_includes_active_agreements(self):
withdrawn_member = GroupAccountMembershipFactory.create(
group=withdrawn_agreement.signed_agreement.anvil_access_group
)
replaced_agreement = factories.MemberAgreementFactory.create(
signed_agreement__status=models.SignedAgreement.StatusChoices.REPLACED
)
replaced_member = GroupAccountMembershipFactory.create(
group=replaced_agreement.signed_agreement.anvil_access_group
)
self.client.force_login(self.user)
response = self.client.get(self.get_url())
self.assertIn("table", response.context_data)
Expand All @@ -5951,6 +5973,7 @@ def test_only_includes_active_agreements(self):
self.assertIn(active_member, table.data)
self.assertNotIn(lapsed_member, table.data)
self.assertNotIn(withdrawn_member, table.data)
self.assertNotIn(replaced_member, table.data)


class CDSAWorkspaceRecordsList(TestCase):
Expand Down Expand Up @@ -6021,6 +6044,11 @@ def test_only_includes_workspaces_with_active_agreements(self):
study=withdrawn_workspace.study,
signed_agreement__status=models.SignedAgreement.StatusChoices.WITHDRAWN,
)
replaced_workspace = factories.CDSAWorkspaceFactory.create()
factories.DataAffiliateAgreementFactory.create(
study=replaced_workspace.study,
signed_agreement__status=models.SignedAgreement.StatusChoices.REPLACED,
)
self.client.force_login(self.user)
response = self.client.get(self.get_url())
self.assertIn("table", response.context_data)
Expand All @@ -6029,6 +6057,7 @@ def test_only_includes_workspaces_with_active_agreements(self):
self.assertIn(active_workspace, table.data)
self.assertNotIn(lapsed_workspace, table.data)
self.assertNotIn(withdrawn_workspace, table.data)
self.assertNotIn(replaced_workspace, table.data)


class CDSAWorkspaceDetailTest(TestCase):
Expand Down
21 changes: 21 additions & 0 deletions primed/collaborative_analysis/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.urls import include, path

from . import views

app_name = "collaborative_analysis"


collaborative_analysis_workspace_patterns = (
[
path(
"<slug:billing_project_slug>/<slug:workspace_slug>/audit/",
views.WorkspaceAudit.as_view(),
name="audit",
),
],
"workspaces",
)

urlpatterns = [
path("workspaces/", include(collaborative_analysis_workspace_patterns)),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% extends "anvil_consortium_manager/base.html" %}

Check warning on line 1 in primed/templates/collaborative_analysis/collaborativeanalysisworkspace_audit.html

View check run for this annotation

Codecov / codecov/patch

primed/templates/collaborative_analysis/collaborativeanalysisworkspace_audit.html#L1

Added line #L1 was not covered by tests

{% block title %}dbGaP workspace audit{% endblock %}

Check warning on line 3 in primed/templates/collaborative_analysis/collaborativeanalysisworkspace_audit.html

View check run for this annotation

Codecov / codecov/patch

primed/templates/collaborative_analysis/collaborativeanalysisworkspace_audit.html#L3

Added line #L3 was not covered by tests


{% block content %}

<h1>Collaborative analysis workspace audit</h1>

<div class="my-3 p-3 bg-light border rounded shadow-sm">
<ul>
<li>Collaborative analysis workspace: <a href="{{ object.get_absolute_url }}">{{ object }}</a></li>
</ul>
</div>

<h2>Audit results</h2>

<div class="my-3 p-3 bg-light border rounded shadow-sm">
<p>
To have access to a Collaborative Analysis Workspace, an account must meet both of the following criteria:

<ul>
<li>Be in the analyst group associated with the workspace</li>
<li>Be in the auth domain for all source workspaces</li>
</ul>
</p>
<p>The audit result categories are explained below.
<ul>

<li><b>Verified</b> includes the following:</li>
<ul>
<li>An account in the analyst group is in the auth domain for this workspace and is in all auth domains for all source workspaces.</li>
<li>An account in the analyst group is <b>not</b> in the auth domain for this workspace and is <b>not</b> in all auth domains for all source workspaces.</li>
</ul>

<li><b>Needs action</b> includes the following:</li>
<ul>
<li>An account in the analyst group is <b>not</b> in the auth domain for this workspace and is in all auth domains for all source workspaces.</li>
<li>An account in the analyst group is in the auth domain for this workspace and is <b>not</b> in all auth domains for all source workspaces.</li>
</ul>

<li><b>Errors</b></li>
<ul>
<li>A group is unexpectedly in the auth domain.</li>
</ul>
</ul>
</p>
<p>Any errors should be reported!</p>
</div>

{% include "__audit_tables.html" with verified_table=verified_table needs_action_table=needs_action_table errors_table=errors_table %}

Check warning on line 52 in primed/templates/collaborative_analysis/collaborativeanalysisworkspace_audit.html

View check run for this annotation

Codecov / codecov/patch

primed/templates/collaborative_analysis/collaborativeanalysisworkspace_audit.html#L7-L52

Added lines #L7 - L52 were not covered by tests
{% endblock content %}

0 comments on commit f0e4484

Please sign in to comment.