Example #1
0
    def test_start_project(self):
        actor_user = UserFactory(is_superuser=True)
        card = AgileCardFactory(
            status=AgileCard.READY,
            recruit_project=None,
            content_item=ProjectContentItemFactory(
                project_submission_type=ContentItem.LINK, template_repo=None),
        )
        self.login(actor_user)

        start_url = f"{self.get_instance_url(card.id)}start_project/"
        response = self.client.post(start_url)
        self.assertEqual(response.status_code, 200)

        card.refresh_from_db()

        # sanity check
        self.assertEqual(card.assignees.count(), 1)

        self.assertEqual(LogEntry.objects.count(), 1)
        entry = LogEntry.objects.first()

        self.assertEqual(entry.actor_user, actor_user)
        self.assertEqual(entry.effected_user, card.assignees.first())
        self.assertEqual(entry.object_1, card.recruit_project)
        self.assertEqual(entry.object_2, None)
        self.assertEqual(entry.event_type.name, creators.CARD_STARTED)
Example #2
0
    def test_project_not_submitted(self):
        team = TeamFactory()
        user = UserFactory()
        team.users.add(user)
        content_item = ProjectContentItemFactory()

        result = get_user_and_projectlink(team, content_item)
        self.assertEqual(result[0], [user.email, None])
Example #3
0
    def test_add_multiple_reviews(self):
        actor_user = UserFactory(is_superuser=True)
        card = AgileCardFactory(
            status=AgileCard.IN_REVIEW,
            # recruit_project=None,
            content_item=ProjectContentItemFactory(
                project_submission_type=ContentItem.LINK, template_repo=None),
        )
        self.login(actor_user)

        add_review_url = f"{self.get_instance_url(card.id)}add_review/"
        response = self.client.post(add_review_url,
                                    data={
                                        "status": COMPETENT,
                                        "comments": "weee"
                                    })
        self.assertEqual(response.status_code, 200)

        card.refresh_from_db()

        self.assertEqual(LogEntry.objects.count(), 2)

        competence_review_entry = LogEntry.objects.all()[0]
        card_to_complete_entry = LogEntry.objects.all()[1]

        self.assertEqual(competence_review_entry.actor_user, actor_user)
        self.assertEqual(competence_review_entry.effected_user,
                         card.assignees.first())
        self.assertEqual(competence_review_entry.event_type.name,
                         creators.COMPETENCE_REVIEW_DONE)
        self.assertEqual(
            competence_review_entry.object_1,
            card.recruit_project.project_reviews.first(),
        )
        self.assertEqual(competence_review_entry.object_2,
                         card.recruit_project)

        self.assertEqual(card_to_complete_entry.actor_user, actor_user)
        self.assertEqual(card_to_complete_entry.effected_user,
                         card.assignees.first())
        self.assertEqual(card_to_complete_entry.event_type.name,
                         creators.CARD_MOVED_TO_COMPLETE)
        self.assertEqual(
            card_to_complete_entry.object_1,
            card.recruit_project,
        )
        self.assertEqual(card_to_complete_entry.object_2, None)

        response = self.client.post(add_review_url,
                                    data={
                                        "status": COMPETENT,
                                        "comments": "blah more stuff"
                                    })
        card.refresh_from_db()

        self.assertEqual(LogEntry.objects.count(), 3)
Example #4
0
 def setUp(self):
     self.actor_user = UserFactory(is_superuser=True, is_staff=True)
     self.content_item = ProjectContentItemFactory(
         project_submission_type=ContentItem.LINK, template_repo=None)
     self.card = AgileCardFactory(
         status=AgileCard.READY,
         recruit_project=RecruitProjectFactory(
             content_item=self.content_item),
         content_item=self.content_item,
     )
     self.login(self.actor_user)
     self.card.start_project()
     self.assertEqual(self.card.status, AgileCard.IN_PROGRESS)
Example #5
0
    def test_log_project_competence_review_envoked_creates_log_entries(self):

        super_user = UserFactory(is_superuser=True)
        card = AgileCardFactory(content_item=ProjectContentItemFactory())
        self.login(super_user)
        response = self.client.post(
            path=f"{self.get_instance_url(pk=card.id)}add_review/",
            data={
                "status": NOT_YET_COMPETENT,
                "comments": "dammit"
            },
        )
        self.assertTrue(response.status_code, 200)
        project_review = RecruitProjectReview.objects.first()
        log_entry = LogEntry.objects.first()
        self.assertEqual(log_entry.actor_user, project_review.reviewer_user)
        self.assertEqual(log_entry.timestamp, project_review.timestamp)
Example #6
0
    def test_log_project_competence_review_envoked(
            self, log_project_competence_review_done,
            log_topic_competence_review_done):

        super_user = UserFactory(is_superuser=True)
        card = AgileCardFactory(content_item=ProjectContentItemFactory())
        self.login(super_user)
        response = self.client.post(
            path=f"{self.get_instance_url(pk=card.id)}add_review/",
            data={
                "status": NOT_YET_COMPETENT,
                "comments": "dammit"
            },
        )
        self.assertTrue(response.status_code, 200)
        project_review = RecruitProjectReview.objects.first()
        log_project_competence_review_done.assert_called_with(project_review)
        log_topic_competence_review_done.assert_not_called()
Example #7
0
    def test_card_moved_to_complete_called(self, log_card_moved_to_complete,
                                           log_card_moved_to_review_feedback):
        actor_user = UserFactory(is_superuser=True)
        card = AgileCardFactory(
            status=AgileCard.IN_REVIEW,
            content_item=ProjectContentItemFactory(
                project_submission_type=ContentItem.LINK, template_repo=None),
        )
        self.login(actor_user)

        add_review_url = f"{self.get_instance_url(card.id)}add_review/"
        response = self.client.post(add_review_url,
                                    data={
                                        "status": COMPETENT,
                                        "comments": "woohoo"
                                    })
        self.assertEqual(response.status_code, 200)

        card.refresh_from_db()
        self.assertEqual(card.status, AgileCard.COMPLETE)
        log_card_moved_to_complete.assert_called_with(card, actor_user)
        log_card_moved_to_review_feedback.assert_not_called()