def test_snapshotdetail_unknown_snapshot(rf): workspace = WorkspaceFactory() request = rf.get("/") with pytest.raises(Http404): SnapshotDetail.as_view()( request, org_slug=workspace.project.org.slug, project_slug=workspace.project.slug, workspace_slug=workspace.name, pk=0, )
def test_snapshotdetail_unpublished_without_permission_to_view(rf): snapshot = SnapshotFactory(published_at=None) request = rf.get("/") request.user = UserFactory() with pytest.raises(Http404): SnapshotDetail.as_view()( request, org_slug=snapshot.workspace.project.org.slug, project_slug=snapshot.workspace.project.slug, workspace_slug=snapshot.workspace.name, pk=snapshot.pk, )
def test_snapshotdetail_unpublished_with_permission_to_view(rf): snapshot = SnapshotFactory(published_at=None) request = rf.get("/") request.user = UserFactory(roles=[ProjectCollaborator]) response = SnapshotDetail.as_view()( request, org_slug=snapshot.workspace.project.org.slug, project_slug=snapshot.workspace.project.slug, workspace_slug=snapshot.workspace.name, pk=snapshot.pk, ) assert response.status_code == 200
def test_snapshotdetail_published_without_permission(rf): snapshot = SnapshotFactory(published_at=timezone.now()) request = rf.get("/") request.user = UserFactory() response = SnapshotDetail.as_view()( request, org_slug=snapshot.workspace.project.org.slug, project_slug=snapshot.workspace.project.slug, workspace_slug=snapshot.workspace.name, pk=snapshot.pk, ) assert response.status_code == 200