Skip to content

Commit

Permalink
Add sharing records to the test data
Browse files Browse the repository at this point in the history
For each point in the upload cycle, add sharing records based on
what they would have been at the previous point in the upload cycle.
This allows us to see what will change at each step during the audit.
  • Loading branch information
amstilp committed Aug 22, 2024
1 parent 19ab046 commit 1ff6226
Showing 1 changed file with 135 additions and 9 deletions.
144 changes: 135 additions & 9 deletions add_upload_workspace_audit_test_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from anvil_consortium_manager.models import WorkspaceGroupSharing
from anvil_consortium_manager.tests.factories import (
ManagedGroupFactory,
WorkspaceGroupSharingFactory,
)
from django.conf import settings
from django.utils import timezone
Expand Down Expand Up @@ -29,7 +31,7 @@
is_future=True,
is_ready_for_compute=False,
)
factories.UploadWorkspaceFactory.create(
workspace = factories.UploadWorkspaceFactory.create(
upload_cycle=upload_cycle,
research_center=rc,
workspace__name="TEST_U01_RC1",
Expand All @@ -46,53 +48,162 @@
research_center=rc,
workspace__name="TEST_U02_RC1",
)
# Create records as appropriate for the previous point in the cycle - future cycle.
# Auth domain.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=workspace.workspace.authorization_domains.first(),
access=WorkspaceGroupSharing.READER,
can_compute=False,
)
# DCC admins.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=dcc_admin_group,
access=WorkspaceGroupSharing.OWNER,
can_compute=True,
)
# DCC writers.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=dcc_writer_group,
access=WorkspaceGroupSharing.WRITER,
can_compute=True,
)
# RC uploaders.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=rc_1_uploader_group,
access=WorkspaceGroupSharing.WRITER,
can_compute=False,
)


# Create a current upload cycle before compute.
# Create a current upload cycle after compute.
upload_cycle = factories.UploadCycleFactory.create(
cycle=3,
is_current=True,
is_ready_for_compute=True,
)
factories.UploadWorkspaceFactory.create(
workspace = factories.UploadWorkspaceFactory.create(
upload_cycle=upload_cycle,
research_center=rc,
workspace__name="TEST_U03_RC1",
)
# Create records as appropriate for the previous point in the cycle - current cycle before compute.
# Auth domain.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=workspace.workspace.authorization_domains.first(),
access=WorkspaceGroupSharing.READER,
can_compute=False,
)
# DCC admins.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=dcc_admin_group,
access=WorkspaceGroupSharing.OWNER,
can_compute=True,
)
# DCC writers.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=dcc_writer_group,
access=WorkspaceGroupSharing.WRITER,
can_compute=True,
)
# RC uploaders.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=rc_1_uploader_group,
access=WorkspaceGroupSharing.WRITER,
can_compute=False,
)

# Create a past upload cycle before QC is completed.
# Create a past upload cycle before qc is completed.
upload_cycle = factories.UploadCycleFactory.create(
cycle=4,
is_current=True,
is_past=True,
is_ready_for_compute=True,
)
factories.UploadWorkspaceFactory.create(
workspace = factories.UploadWorkspaceFactory.create(
upload_cycle=upload_cycle,
research_center=rc,
workspace__name="TEST_U04_RC1",
date_qc_completed=None,
)
# Create records as appropriate for the previous point in the cycle - current cycle after compute.
# Auth domain.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=workspace.workspace.authorization_domains.first(),
access=WorkspaceGroupSharing.READER,
can_compute=False,
)
# DCC admins.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=dcc_admin_group,
access=WorkspaceGroupSharing.OWNER,
can_compute=True,
)
# DCC writers.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=dcc_writer_group,
access=WorkspaceGroupSharing.WRITER,
can_compute=True,
)
# RC uploaders.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=rc_1_uploader_group,
access=WorkspaceGroupSharing.WRITER,
can_compute=True,
)

# Create a past upload cycle after QC is completed.
upload_cycle = factories.UploadCycleFactory.create(
cycle=5,
is_current=True,
is_past=True,
is_ready_for_compute=True,
)
factories.UploadWorkspaceFactory.create(
workspace = factories.UploadWorkspaceFactory.create(
upload_cycle=upload_cycle,
research_center=rc,
workspace__name="TEST_U05_RC1",
date_qc_completed=timezone.now(),
)
# Create records as appropriate for the previous point in the cycle - past cycle before QC complete.
# Auth domain.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=workspace.workspace.authorization_domains.first(),
access=WorkspaceGroupSharing.READER,
can_compute=False,
)
# DCC admins.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=dcc_admin_group,
access=WorkspaceGroupSharing.OWNER,
can_compute=True,
)
# DCC writers.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=dcc_writer_group,
access=WorkspaceGroupSharing.WRITER,
can_compute=True,
)

# Create a past upload cycle with a combined workspace.
upload_cycle = factories.UploadCycleFactory.create(
cycle=6,
is_past=True,
is_ready_for_compute=True,
)
factories.UploadWorkspaceFactory.create(
workspace = factories.UploadWorkspaceFactory.create(
upload_cycle=upload_cycle,
research_center=rc,
workspace__name="TEST_U06_RC1",
Expand All @@ -103,3 +214,18 @@
date_completed=timezone.now(),
workspace__name="TEST_U06_COMBINED",
)
# Create records as appropriate for the previous point in the cycle - past cycle before QC complete.
# Auth domain.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=workspace.workspace.authorization_domains.first(),
access=WorkspaceGroupSharing.READER,
can_compute=False,
)
# DCC admins.
WorkspaceGroupSharingFactory.create(
workspace=workspace.workspace,
group=dcc_admin_group,
access=WorkspaceGroupSharing.OWNER,
can_compute=True,
)

0 comments on commit 1ff6226

Please sign in to comment.