def setUpTestData(cls): cls.project = ProjectFactory() cls.project_dict = cls.project.__dict__ cls.assignment_1 = ProjectAssignmentFactory(project=cls.project) cls.assignment_2 = ProjectAssignmentFactory(project=cls.project) cls.to_be_deleted = ProjectAssignmentFactory(project=cls.project) cls.new_assignee = UserFactory()
def setUpTestData(cls): cls.user = UserFactory(password=PASSWORD) cls.Project = ProjectFactory._meta.model cls.ProjectAssignment = ProjectAssignmentFactory._meta.model cls.ReportFindingLink = ReportFindingLinkFactory._meta.model cls.current_project = ProjectFactory( start_date=date.today() - timedelta(days=14), end_date=date.today(), complete=True ) cls.future_project = ProjectFactory( start_date=date.today() + timedelta(days=14), end_date=date.today() + timedelta(days=28), complete=False ) ProjectAssignmentFactory( project=cls.current_project, operator=cls.user, start_date=date.today(), end_date=date.today() + timedelta(days=14), ) ProjectAssignmentFactory( project=cls.future_project, operator=cls.user, start_date=date.today() + timedelta(days=14), end_date=date.today() + timedelta(days=28), ) cls.report = ReportFactory(project=cls.current_project) ReportFindingLinkFactory.create_batch(3, report=cls.report, assigned_to=cls.user) cls.user_tasks = ( cls.ReportFindingLink.objects.select_related("report", "report__project") .filter( Q(assigned_to=cls.user) & Q(report__complete=False) & Q(complete=False) ) .order_by("report__project__end_date")[:10] ) cls.user_projects = cls.ProjectAssignment.objects.select_related( "project", "project__client", "role" ).filter(Q(operator=cls.user)) cls.active_projects = cls.ProjectAssignment.objects.select_related( "project", "project__client", "role" ).filter(Q(operator=cls.user) & Q(project__complete=False)) cls.uri = reverse("home:dashboard")
def test_crud_finding(self): # Create assignment = ProjectAssignmentFactory(operator=self.user) # Read self.assertEqual(assignment.operator, self.user) self.assertEqual(assignment.pk, assignment.id) self.assertQuerysetEqual( self.ProjectAssignment.objects.all(), [ f"<ProjectAssignment: {self.user} - {assignment.project} {assignment.end_date})>" ], ) # Update assignment.operator = self.new_user assignment.save() self.assertQuerysetEqual( self.ProjectAssignment.objects.all(), [ f"<ProjectAssignment: {self.new_user} - {assignment.project} {assignment.end_date})>" ], ) # Delete assignment.delete() assert not self.ProjectAssignment.objects.all().exists()
def setUpTestData(cls): cls.group_1 = GroupFactory(name="Group 1") cls.group_2 = GroupFactory(name="Group 2") cls.user = UserFactory(password=PASSWORD, groups=(cls.group_1,)) cls.project = ProjectFactory() cls.report = ReportFactory(project=cls.project) cls.assignment = ProjectAssignmentFactory(project=cls.project, operator=cls.user) cls.num_of_findings = 3 ReportFindingLinkFactory.create_batch( cls.num_of_findings, report=cls.report, assigned_to=cls.user ) cls.uri = reverse("home:dashboard")
def setUpTestData(cls): cls.assignment = ProjectAssignmentFactory() cls.assignment_dict = cls.assignment.__dict__ cls.new_assignee = UserFactory()