Exemplo n.º 1
0
    def test_user_cannot_upload_when_latest_is_approved(self):
        applicant = ApplicantFactory()
        staff = StaffFactory()

        project = ProjectFactory(status=CONTRACTING)
        ContractFactory(project=project, is_signed=True, approver=staff)
        self.assertFalse(user_can_upload_contract(project, applicant))
Exemplo n.º 2
0
    def test_applicant_and_staff_cant_edit_in_under_review(self):
        payment_request = PaymentRequestFactory(status=UNDER_REVIEW)
        applicant = ApplicantFactory()
        staff = StaffFactory()

        self.assertFalse(can_edit(payment_request, applicant))
        self.assertFalse(can_edit(payment_request, staff))
Exemplo n.º 3
0
    def test_applicant_and_staff_cant_edit_in_decline(self):
        payment_request = PaymentRequestFactory(status=DECLINED)
        applicant = ApplicantFactory()
        staff = StaffFactory()

        self.assertFalse(can_edit(payment_request, applicant))
        self.assertFalse(can_edit(payment_request, staff))
Exemplo n.º 4
0
    def test_applicant_and_staff_can_edit_in_submitted(self):
        payment_request = PaymentRequestFactory(status=SUBMITTED)
        applicant = ApplicantFactory()
        staff = StaffFactory()

        self.assertTrue(can_edit(payment_request, applicant))
        self.assertTrue(can_edit(payment_request, staff))
Exemplo n.º 5
0
    def test_user_upload_happy_path(self):
        applicant = ApplicantFactory()

        project = ProjectFactory(status=CONTRACTING)
        ContractFactory(project=project, is_signed=True, approver=None)
        self.assertTrue(user_can_upload_contract(project, applicant))

        project = ProjectFactory(status=IN_PROGRESS)
        ContractFactory(project=project, is_signed=True, approver=None)
        self.assertTrue(user_can_upload_contract(project, applicant))
Exemplo n.º 6
0
    def test_staff_only(self):
        factory = RequestFactory()
        submission = ApplicationSubmissionFactory()
        ProjectFactory(submission=submission)

        request = factory.get(f'/submission/{submission.pk}')
        request.user = StaffFactory()

        response = SubmissionDetailSimplifiedView.as_view()(request, pk=submission.pk)
        self.assertEqual(response.status_code, 200)

        request.user = ApplicantFactory()
        with self.assertRaises(PermissionDenied):
            SubmissionDetailSimplifiedView.as_view()(request, pk=submission.pk)
Exemplo n.º 7
0
    def test_slack_applicant_update_payment_request(self):
        responses.add(responses.POST, self.target_url, status=200, body='OK')

        project = self.source_factory()
        payment_request = PaymentRequestFactory(project=project)
        applicant = ApplicantFactory()

        self.adapter_process(
            MESSAGES.UPDATE_PAYMENT_REQUEST,
            adapter=self.slack(),
            user=applicant,
            source=project,
            related=payment_request,
        )

        self.assertEqual(len(responses.calls), 1)

        data = json.loads(responses.calls[0].request.body)
        self.assertIn(str(applicant), data['message'])
        self.assertIn(str(project), data['message'])
Exemplo n.º 8
0
    def test_user_can_only_upload_during_contracting(self):
        applicant = ApplicantFactory()

        project = ProjectFactory(status=COMMITTED)
        ContractFactory(project=project, is_signed=True, approver=None)
        self.assertTrue(user_can_upload_contract(project, applicant))

        project = ProjectFactory(status=CONTRACTING)
        ContractFactory(project=project, is_signed=True, approver=None)
        self.assertTrue(user_can_upload_contract(project, applicant))

        project = ProjectFactory(status=IN_PROGRESS)
        ContractFactory(project=project, is_signed=True, approver=None)
        self.assertTrue(user_can_upload_contract(project, applicant))

        project = ProjectFactory(status=COMPLETE)
        ContractFactory(project=project, is_signed=True, approver=None)
        self.assertTrue(user_can_upload_contract(project, applicant))

        project = ProjectFactory(status=CLOSING)
        ContractFactory(project=project, is_signed=True, approver=None)
        self.assertTrue(user_can_upload_contract(project, applicant))
Exemplo n.º 9
0
    def test_user_cannot_upload_first_contract(self):
        applicant = ApplicantFactory()

        project = ProjectFactory(status=CONTRACTING)
        self.assertFalse(user_can_upload_contract(project, applicant))
Exemplo n.º 10
0
    def test_applicant_can_edit_in_changes_requested(self):
        payment_request = PaymentRequestFactory(status=CHANGES_REQUESTED)
        applicant = ApplicantFactory()

        self.assertTrue(can_edit(payment_request, applicant))
Exemplo n.º 11
0
    def test_user_cant_delete_from_declined(self):
        payment_request = PaymentRequestFactory(status=DECLINED)
        user = ApplicantFactory()

        self.assertFalse(can_delete(payment_request, user))
Exemplo n.º 12
0
    def test_user_cant_delete_from_paid(self):
        payment_request = PaymentRequestFactory(status=PAID)
        user = ApplicantFactory()

        self.assertFalse(can_delete(payment_request, user))
Exemplo n.º 13
0
    def test_user_can_delete_from_changes_requested(self):
        payment_request = PaymentRequestFactory(status=CHANGES_REQUESTED)
        user = ApplicantFactory()

        self.assertTrue(can_delete(payment_request, user))
Exemplo n.º 14
0
    def test_user_cant_delete_from_under_review(self):
        payment_request = PaymentRequestFactory(status=UNDER_REVIEW)
        user = ApplicantFactory()

        self.assertFalse(can_delete(payment_request, user))
Exemplo n.º 15
0
    def test_user_can_delete_from_submitted(self):
        payment_request = PaymentRequestFactory(status=SUBMITTED)
        user = ApplicantFactory()

        self.assertTrue(can_delete(payment_request, user))
Exemplo n.º 16
0
    def test_user_cant_change_status_from_submitted(self):
        payment_request = PaymentRequestFactory(status=SUBMITTED)
        user = ApplicantFactory()

        self.assertFalse(can_change_status(payment_request, user))