|
6 | 6 | from django.core.files.temp import NamedTemporaryFile |
7 | 7 | from ulid import ULID |
8 | 8 |
|
| 9 | +from apps.contributor.factories import ContributorTeamFactory |
9 | 10 | from apps.project.factories import OrganizationFactory, ProjectFactory |
10 | 11 | from apps.project.models import ( |
11 | 12 | Project, |
@@ -496,6 +497,16 @@ def test_project_create(self): |
496 | 497 | response = content["data"]["createProject"] |
497 | 498 | assert response["errors"] is not None, content |
498 | 499 |
|
| 500 | + # Creating project with archived team |
| 501 | + # Fails as team is archived |
| 502 | + archived_team = ContributorTeamFactory.create( |
| 503 | + **self.user_resource_kwargs, |
| 504 | + is_archived=True, |
| 505 | + ) |
| 506 | + project_data["team"] = archived_team.pk |
| 507 | + response = content["data"]["createProject"] |
| 508 | + assert response["errors"] is not None, content |
| 509 | + |
499 | 510 | latest_project = Project.objects.get(pk=resp_data["result"]["id"]) |
500 | 511 | assert latest_project.created_by_id == self.user.pk |
501 | 512 | assert latest_project.modified_by_id == self.user.pk |
@@ -613,6 +624,16 @@ def test_project_update(self, mock_requests): |
613 | 624 | ), |
614 | 625 | ), content |
615 | 626 |
|
| 627 | + # Updating project with archived team |
| 628 | + # fails as team is archived |
| 629 | + archived_team = ContributorTeamFactory.create( |
| 630 | + **self.user_resource_kwargs, |
| 631 | + is_archived=True, |
| 632 | + ) |
| 633 | + project_data["team"] = archived_team.pk |
| 634 | + content = self._update_project_mutation(str(latest_project.pk), project_data) |
| 635 | + assert content["data"]["updateProject"]["errors"] is not None, content |
| 636 | + |
616 | 637 | # Updating project with archived Organization |
617 | 638 | # Fails as organization is archived |
618 | 639 | archived_organization = OrganizationFactory.create( |
@@ -819,6 +840,16 @@ def test_project_update(self, mock_requests): |
819 | 840 | assert content["data"]["updateProcessedProject"]["errors"] is None, content |
820 | 841 | assert content["data"]["updateProcessedProject"]["result"]["status"] == self.genum(ProjectStatusEnum.ARCHIVED) |
821 | 842 |
|
| 843 | + # Updating project with archived team |
| 844 | + # fails as team is archived |
| 845 | + archived_team = ContributorTeamFactory.create( |
| 846 | + **self.user_resource_kwargs, |
| 847 | + is_archived=True, |
| 848 | + ) |
| 849 | + project_data["team"] = archived_team.pk |
| 850 | + content = self._update_processed_project_mutation(str(latest_project.pk), project_data) |
| 851 | + assert content["data"]["updateProcessedProject"]["errors"] is not None, content |
| 852 | + |
822 | 853 |
|
823 | 854 | class TestProjectTypeMutation(TestCase): |
824 | 855 | @typing.override |
|
0 commit comments