def setUp(self):
     super(TestAmendmentsInvalid, self).setUp()
     self.intervention = InterventionFactory(status=Intervention.DRAFT, )
     self.intervention.old_instance = self.intervention
     self.amendment = InterventionAmendmentFactory(
         intervention=self.intervention,
         signed_date=datetime.date(2001, 1, 1),
         signed_amendment="random.pdf",
     )
Exemplo n.º 2
0
 def setUpTestData(cls):
     cls.file_type_partner = AttachmentFileTypeFactory(
         code="partners_partner_assessment")
     cls.file_type_agreement = AttachmentFileTypeFactory(
         code="partners_agreement")
     cls.file_type_assessment = AttachmentFileTypeFactory(
         code="partners_assessment_report")
     cls.file_type_agreement_amendment = AttachmentFileTypeFactory(
         code="partners_agreement_amendment")
     cls.file_type_intervention_prc_review = AttachmentFileTypeFactory(
         code="partners_intervention_prc_review")
     cls.file_type_intervention_signed_pd = AttachmentFileTypeFactory(
         code="partners_intervention_signed_pd")
     cls.file_type_intervention_amendment = AttachmentFileTypeFactory(
         code="partners_intervention_amendment_signed")
     cls.file_type_intervention_attachment = AttachmentFileTypeFactory(
         code="partners_intervention_attachment")
     cls.partner = PartnerFactory()
     cls.core_values_assessment = CoreValuesAssessmentFactory(
         assessment="sample.pdf")
     cls.agreement = AgreementFactory(attached_agreement="sample.pdf")
     cls.assessment = AssessmentFactory(report="sample.pdf")
     cls.agreement_amendment = AgreementAmendmentFactory(
         signed_amendment="sample.pdf")
     cls.intervention = InterventionFactory(
         prc_review_document="prc_sample.pdf",
         signed_pd_document="pd_sample.pdf")
     cls.intervention_amendment = InterventionAmendmentFactory(
         signed_amendment="sample.pdf")
     cls.intervention_attachment = InterventionAttachmentFactory(
         attachment="sample.pdf")
Exemplo n.º 3
0
    def setUpTestData(cls):
        cls.code_1 = "test_code_1"
        cls.file_type_1 = AttachmentFileTypeFactory(code=cls.code_1)
        cls.code_2 = "test_code_2"
        cls.file_type_2 = AttachmentFileTypeFactory(code=cls.code_2)
        cls.unicef_staff = UserFactory(is_staff=True)
        cls.user = UserFactory()
        cls.url = reverse("attachments:list")
        cls.attachment_1 = AttachmentFactory(
            file_type=cls.file_type_1,
            code=cls.code_1,
            file="sample1.pdf",
            content_object=cls.file_type_1,
            uploaded_by=cls.unicef_staff
        )
        cls.attachment_2 = AttachmentFactory(
            file_type=cls.file_type_2,
            code=cls.code_2,
            file="sample2.pdf",
            content_object=cls.file_type_2,
            uploaded_by=cls.user
        )

        cls.partner = PartnerFactory(
            partner_type=PartnerType.UN_AGENCY,
            vendor_number="V123",
        )
        cls.agreement = AgreementFactory(partner=cls.partner)
        cls.assessment = AssessmentFactory(partner=cls.partner)
        cls.amendment = AgreementAmendmentFactory(agreement=cls.agreement)
        cls.intervention = InterventionFactory(agreement=cls.agreement)
        cls.result_link = InterventionResultLinkFactory(
            intervention=cls.intervention
        )
        cls.intervention_amendment = InterventionAmendmentFactory(
            intervention=cls.intervention
        )
        cls.intervention_attachment = InterventionAttachmentFactory(
            intervention=cls.intervention
        )

        cls.tpm_partner = SimpleTPMPartnerFactory(vendor_number="V432")
        cls.tpm_visit = TPMVisitFactory(tpm_partner=cls.tpm_partner)
        cls.tpm_activity = TPMActivityFactory(
            partner=cls.partner,
            intervention=cls.intervention,
            tpm_visit=cls.tpm_visit
        )

        cls.engagement = EngagementFactory(partner=cls.partner)

        cls.default_partner_response = [{
            "partner": "",
            "partner_type": "",
            "vendor_number": "",
            "pd_ssfa_number": "",
            "agreement_reference_number": "",
            "source": "",
        }] * 2
Exemplo n.º 4
0
 def test_no_issue(self):
     """Check that if amendment file, then issue is NOT raised"""
     amendment = InterventionAmendmentFactory()
     self.assertTrue(amendment.signed_amendment)
     self.assertFalse(self.qs_issue.exists())
     checks.bootstrap_checks(default_is_active=True)
     checks.run_all_checks()
     self.assertFalse(self.qs_issue.exists())
Exemplo n.º 5
0
 def test_run_all_checks(self):
     UserFactory(username="******")
     qs_issue = FlaggedIssue.objects.filter(
         issue_id="interventions_amendments_no_file")
     InterventionAmendmentFactory(signed_amendment=None)
     checks.bootstrap_checks(default_is_active=True)
     self.assertFalse(qs_issue.exists())
     tasks.run_all_checks_task()
     self.assertTrue(qs_issue.exists())
Exemplo n.º 6
0
 def test_no_amendment_file(self):
     """Check that if no amendment file, then issue is raised"""
     amendment = InterventionAmendmentFactory(signed_amendment=None)
     self.assertFalse(amendment.signed_amendment)
     self.assertFalse(self.qs_issue.exists())
     checks.bootstrap_checks(default_is_active=True)
     checks.run_all_checks()
     self.assertTrue(self.qs_issue.exists())
     issue = self.qs_issue.first()
     self.assertIn("has missing amendment file", issue.message)
 def setUp(self):
     super().setUp()
     self.intervention = InterventionFactory(
         status=Intervention.DRAFT,
     )
     self.intervention.old_instance = self.intervention
     self.amendment = InterventionAmendmentFactory(
         intervention=self.intervention,
         signed_date=datetime.date(2001, 1, 1),
         signed_amendment="random.pdf",
     )
Exemplo n.º 8
0
 def test_recheck_all_open_issues_task(self):
     UserFactory(username="******")
     amendment = InterventionAmendmentFactory()
     issue = FlaggedIssueFactory(
         content_object=amendment,
         issue_id='interventions_amendments_no_file',
         issue_status=ISSUE_STATUS_NEW,
     )
     tasks.recheck_all_open_issues_task()
     issue_updated = FlaggedIssue.objects.get(pk=issue.pk)
     self.assertEqual(issue_updated.issue_status, ISSUE_STATUS_RESOLVED)
Exemplo n.º 9
0
 def test_intervention_amendment(self):
     amendment = InterventionAmendmentFactory(
         intervention=self.intervention
     )
     attachment = AttachmentFactory(content_object=amendment)
     file_path = models.generate_file_path(attachment, "test.pdf")
     self.assert_file_path(file_path, [
         str(self.partner.pk),
         "agreements",
         str(self.agreement.pk),
         "interventions",
         str(self.intervention.pk),
         "amendments",
         str(amendment.pk),
         "test.pdf"
     ], "partners")
     # check against old file path function
     file_path_old = partner_models.get_intervention_amendment_file_path(
         amendment,
         "test.pdf"
     )
     self.assertEqual(file_path, file_path_old)
Exemplo n.º 10
0
class TestAmendmentsInvalid(BaseTenantTestCase):
    def setUp(self):
        super().setUp()
        self.intervention = InterventionFactory(
            status=Intervention.DRAFT,
        )
        self.intervention.old_instance = self.intervention
        self.amendment = InterventionAmendmentFactory(
            intervention=self.intervention,
            signed_date=datetime.date(2001, 1, 1),
            signed_amendment="random.pdf",
        )

    @skip("update teste with new amendment style")
    def test_valid(self):
        pass
        # self.assertTrue(amendments_valid(self.intervention))

    @skip("update testes with new amendment style")
    def test_change_invalid(self):
        """If not active/signed and amendment changes then invalid"""
        self.amendment.signed_date = datetime.date.today()
        self.amendment.save()
        # mock_check = Mock(return_value=False)
        # with patch(
        #         "etools.applications.partners.validation.interventions.check_rigid_related",
        #         mock_check
        # ):
        #    self.assertFalse(amendments_valid(self.intervention))

    @skip("update teste with new amendment style")
    def test_change_active_valid(self):
        """If active and amendment changes then valid"""
        self.intervention.status = Intervention.ACTIVE
        self.amendment.signed_date = datetime.date.today()
        self.amendment.save()
        # self.assertTrue(amendments_valid(self.intervention))

    @skip("update tests with new amendment style")
    def test_change_signed_valid(self):
        """If signed and amendment changes then valid"""
        self.intervention.status = Intervention.SIGNED
        self.amendment.signed_date = datetime.date.today()
        # self.assertTrue(amendments_valid(self.intervention))

    @skip("update tests with new amendment style")
    def test_other_no_description(self):
        """If amendment is type other, and no other description then invalid"""
        self.amendment.types = [InterventionAmendment.OTHER]
        self.amendment.other_description = None
        self.amendment.save()
        self.assertIsNone(self.amendment.other_description)
        # self.assertFalse(amendments_valid(self.intervention))

    @skip("update tests with new amendment style")
    def test_other_with_description(self):
        """If amendment is type other, and no other description then valid"""
        self.amendment.types = [InterventionAmendment.OTHER]
        self.amendment.other_description = "Description"
        self.amendment.save()
        self.assertIsNotNone(self.amendment.other_description)
        # self.assertTrue(amendments_valid(self.intervention))

    @skip("update tests with new amendment style")
    def test_no_signed_date(self):
        """If amendment has no signed date then invalid"""
        self.amendment.signed_date = None
        self.amendment.save()
        # self.assertFalse(amendments_valid(self.intervention))

    @skip("update tests with new amendment style")
    def test_no_signed_amendment(self):
        """If amendment has no signed amendment then invalid"""
        self.amendment.signed_amendment = None
        self.amendment.save()
Exemplo n.º 11
0
 def setUp(self):
     super(TestInterventionAmendmentModelExport, self).setUp()
     self.amendment = InterventionAmendmentFactory(
         intervention=self.intervention, )
class TestAmendmentsInvalid(BaseTenantTestCase):
    def setUp(self):
        super(TestAmendmentsInvalid, self).setUp()
        self.intervention = InterventionFactory(status=Intervention.DRAFT, )
        self.intervention.old_instance = self.intervention
        self.amendment = InterventionAmendmentFactory(
            intervention=self.intervention,
            signed_date=datetime.date(2001, 1, 1),
            signed_amendment="random.pdf",
        )

    @skip("update teste with new amendment style")
    def test_valid(self):
        pass
        # self.assertTrue(amendments_valid(self.intervention))

    @skip("update testes with new amendment style")
    def test_change_invalid(self):
        """If not active/signed and amendment changes then invalid"""
        self.amendment.signed_date = datetime.date.today()
        self.amendment.save()
        # mock_check = Mock(return_value=False)
        # with patch(
        #         "etools.applications.partners.validation.interventions.check_rigid_related",
        #         mock_check
        # ):
        #    self.assertFalse(amendments_valid(self.intervention))

    @skip("update teste with new amendment style")
    def test_change_active_valid(self):
        """If active and amendment changes then valid"""
        self.intervention.status = Intervention.ACTIVE
        self.amendment.signed_date = datetime.date.today()
        self.amendment.save()
        # self.assertTrue(amendments_valid(self.intervention))

    @skip("update tests with new amendment style")
    def test_change_signed_valid(self):
        """If signed and amendment changes then valid"""
        self.intervention.status = Intervention.SIGNED
        self.amendment.signed_date = datetime.date.today()
        # self.assertTrue(amendments_valid(self.intervention))

    @skip("update tests with new amendment style")
    def test_other_no_description(self):
        """If amendment is type other, and no other description then invalid"""
        self.amendment.types = [InterventionAmendment.OTHER]
        self.amendment.other_description = None
        self.amendment.save()
        self.assertIsNone(self.amendment.other_description)
        # self.assertFalse(amendments_valid(self.intervention))

    @skip("update tests with new amendment style")
    def test_other_with_description(self):
        """If amendment is type other, and no other description then valid"""
        self.amendment.types = [InterventionAmendment.OTHER]
        self.amendment.other_description = "Description"
        self.amendment.save()
        self.assertIsNotNone(self.amendment.other_description)
        # self.assertTrue(amendments_valid(self.intervention))

    @skip("update tests with new amendment style")
    def test_no_signed_date(self):
        """If amendment has no signed date then invalid"""
        self.amendment.signed_date = None
        self.amendment.save()
        # self.assertFalse(amendments_valid(self.intervention))

    @skip("update tests with new amendment style")
    def test_no_signed_amendment(self):
        """If amendment has no signed amendment then invalid"""
        self.amendment.signed_amendment = None
        self.amendment.save()
Exemplo n.º 13
0
 def get_fixtures(cls):
     return {'intervention': InterventionFactory(id=101),
             'amendment': InterventionAmendmentFactory(),
             'result': InterventionResultLinkFactory(),
             }
Exemplo n.º 14
0
 def setUp(self):
     super().setUp()
     self.amendment = InterventionAmendmentFactory(
         intervention=self.intervention, )