Exemplo n.º 1
0
    def test_create_wrong_category(self):
        data = {
            'category':
            ActionPointCategoryFactory(module=Category.MODULE_CHOICES.audit).id
        }
        data.update(self.create_data)

        response = self.forced_auth_req(
            'post',
            reverse('action-points:action-points-list'),
            data=data,
            user=self.unicef_user)

        self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
        self.assertIn('category', response.data)
Exemplo n.º 2
0
    def test_update_related_category(self):
        action_point = ActionPointFactory(status='open',
                                          comments__count=0,
                                          engagement=MicroAssessmentFactory())

        response = self.forced_auth_req(
            'patch',
            reverse('action-points:action-points-detail',
                    args=(action_point.id, )),
            user=action_point.author,
            data={
                'category':
                ActionPointCategoryFactory(
                    module=Category.MODULE_CHOICES.audit).id
            })

        self.assertEqual(response.status_code, status.HTTP_200_OK)
Exemplo n.º 3
0
    def test_action_point_added(self):
        self._init_finalized_engagement()
        self.assertEqual(self.engagement.action_points.count(), 0)

        response = self.forced_auth_req(
            'post',
            '/api/audit/engagements/{}/action-points/'.format(
                self.engagement.id),
            user=self.unicef_focal_point,
            data={
                'category': ActionPointCategoryFactory(module='audit').id,
                'description': fuzzy.FuzzyText(length=100).fuzz(),
                'due_date': fuzzy.FuzzyDate(datetime.date(2001, 1, 1)).fuzz(),
                'assigned_to': self.unicef_user.id,
                'section': SectionFactory().id,
                'office': self.unicef_focal_point.profile.office.id,
            })

        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(self.engagement.action_points.count(), 1)
        self.assertIsNotNone(self.engagement.action_points.first().partner)
Exemplo n.º 4
0
    def setUpTestData(cls):
        cls.user = UserFactory(unicef_user=True)

        for module, display_value in Category.MODULE_CHOICES:
            ActionPointCategoryFactory(module=module)