예제 #1
0
    def test_finance2_choices_with_submitted_status(self):
        invoice = InvoiceFactory(status=SUBMITTED)
        user = Finance2Factory()
        form = ChangeInvoiceStatusForm(instance=invoice, user=user)

        expected = set(filter_request_choices([CHANGES_REQUESTED_BY_STAFF, APPROVED_BY_STAFF, DECLINED], invoice_status_user_choices(user)))
        actual = set(form.fields['status'].choices)
        self.assertEqual(expected, actual)
예제 #2
0
    def test_finance2_choices_with_changes_requested_by_finance2_status(self):
        invoice = InvoiceFactory(status=CHANGES_REQUESTED_BY_FINANCE_2)
        user = Finance2Factory()
        form = ChangeInvoiceStatusForm(instance=invoice, user=user)

        expected = set(filter_request_choices([CHANGES_REQUESTED_BY_FINANCE_1, APPROVED_BY_FINANCE_1],
                                              invoice_status_user_choices(user)))
        actual = set(form.fields['status'].choices)
        self.assertEqual(expected, actual)
예제 #3
0
    def test_finance2_can_add_deliverables(self):
        user = Finance2Factory()
        project = ProjectFactory()
        invoice = InvoiceFactory(project=project, status=APPROVED_BY_FINANCE_1)
        deliverable = DeliverableFactory(project=project)
        self.client.force_login(user)

        response = self.post_to_add(project.id, invoice.id, deliverable.id)
        self.assertEqual(response.status_code, 201)
예제 #4
0
 def test_finance2_cant_edit_deliverables(self):
     statuses = [
         APPROVED_BY_FINANCE_2, APPROVED_BY_STAFF,
         CHANGES_REQUESTED_BY_FINANCE_1, CHANGES_REQUESTED_BY_FINANCE_2,
         CHANGES_REQUESTED_BY_STAFF, DECLINED, PAID, SUBMITTED, RESUBMITTED
     ]
     user = Finance2Factory()
     for status in statuses:
         invoice = InvoiceFactory(status=status)
         self.assertFalse(invoice.can_user_edit_deliverables(user))
예제 #5
0
    def test_finance2_can_remove_deliverables(self):
        user = Finance2Factory()
        project = ProjectFactory()
        invoice = InvoiceFactory(project=project, status=APPROVED_BY_FINANCE_1)
        deliverable = DeliverableFactory(project=project)
        invoice_deliverable = InvoiceDeliverableFactory(deliverable=deliverable)
        invoice.deliverables.add(invoice_deliverable)
        self.client.force_login(user)

        response = self.delete_to_remove(project.id, invoice.id, invoice_deliverable.id)
        self.assertEqual(response.status_code, 200)
예제 #6
0
    def test_finance2_cant_get_set_required_valid_checks(self):
        user = Finance2Factory()
        project = ProjectFactory()
        invoice = InvoiceFactory(project=project, status=APPROVED_BY_STAFF)
        valid_checks = True
        valid_checks_link = 'https://google.com'

        self.client.force_login(user)
        response = self.post_to_set(project.id, invoice.id, valid_checks, valid_checks_link)
        self.assertEqual(response.status_code, 403)

        response = self.get_to_retrieve(project.id, invoice.id)
        self.assertEqual(response.status_code, 403)
예제 #7
0
    def test_deliverables_cant_removed_after_finance2_approval(self):
        project = ProjectFactory()
        invoice = InvoiceFactory(project=project, status=APPROVED_BY_FINANCE_2)
        deliverable = DeliverableFactory(project=project)
        invoice_deliverable = InvoiceDeliverableFactory(deliverable=deliverable)
        invoice.deliverables.add(invoice_deliverable)

        finance1 = FinanceFactory()
        finance2 = Finance2Factory()
        staff = StaffFactory()
        for user in [staff, finance1, finance2]:
            self.client.force_login(user)
            response = self.delete_to_remove(project.id, invoice.id, invoice_deliverable.id)
            self.assertEqual(response.status_code, 403)
예제 #8
0
    def test_invoice_status_user_choices(self):
        applicant = ApplicantFactory()
        staff = StaffFactory()
        finance1 = FinanceFactory()
        finance2 = Finance2Factory()
        applicant_choices = invoice_status_user_choices(applicant)
        self.assertEqual(applicant_choices, [])

        staff_choices = invoice_status_user_choices(staff)
        self.assertEqual(staff_choices, INVOICE_STATUS_PM_CHOICES)

        finance1_choices = invoice_status_user_choices(finance1)
        self.assertEqual(finance1_choices, INVOICE_STATUS_FINANCE_1_CHOICES)

        finance2_choices = invoice_status_user_choices(finance2)
        self.assertEqual(finance2_choices, INVOICE_STATUS_FINANCE_2_CHOICES)
예제 #9
0
 def test_finance2_can_edit_deliverables(self):
     statuses = [APPROVED_BY_FINANCE_1]
     user = Finance2Factory()
     for status in statuses:
         invoice = InvoiceFactory(status=status)
         self.assertTrue(invoice.can_user_edit_deliverables(user))
예제 #10
0
 def test_finance2_can_view_required_checks(self):
     user = Finance2Factory()
     invoice = InvoiceFactory(status=APPROVED_BY_FINANCE_1)
     self.assertTrue(invoice.can_user_view_required_checks(user))
예제 #11
0
 def test_finance2_cant_complete_required_checks(self):
     statuses = [APPROVED_BY_STAFF, CHANGES_REQUESTED_BY_FINANCE_2]
     user = Finance2Factory()
     for status in statuses:
         invoice = InvoiceFactory(status=status)
         self.assertFalse(invoice.can_user_complete_required_checks(user))
예제 #12
0
 def test_finance2_can_change_status(self):
     statuses = [APPROVED_BY_FINANCE_1, APPROVED_BY_FINANCE_2, CONVERTED]
     user = Finance2Factory()
     for status in statuses:
         invoice = InvoiceFactory(status=status)
         self.assertTrue(invoice.can_user_change_status(user))