Skip to content

Commit

Permalink
Added unit tests for status partial
Browse files Browse the repository at this point in the history
  • Loading branch information
wes-otf committed Aug 14, 2024
1 parent ebb7e0d commit 94b462f
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions hypha/apply/projects/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ def test_can(self):
invoice.refresh_from_db()
self.assertEqual(invoice.status, CHANGES_REQUESTED_BY_STAFF)

def test_can_view_updated_invoice(self):
def test_can_view_updated_invoice_table(self):
project = ProjectFactory()
invoice = InvoiceFactory(project=project)
response = self.post_page(
Expand All @@ -1099,7 +1099,7 @@ def test_can_view_updated_invoice(self):
response, get_invoice_status_display_value(CHANGES_REQUESTED_BY_STAFF)
)

def test_can_view_updated_rejected_invoice(self):
def test_can_view_updated_rejected_invoice_table(self):
project = ProjectFactory()
invoice = InvoiceFactory(project=project)
response = self.post_page(
Expand Down Expand Up @@ -1136,6 +1136,44 @@ def test_can_view_updated_rejected_invoice(self):
rejected_response, get_invoice_status_display_value(DECLINED)
)

def test_can_view_updated_invoice_status(self):
project = ProjectFactory()
invoice = InvoiceFactory(project=project)

response = self.client.get(
reverse(
"apply:projects:partial-invoice-status",
kwargs={"pk": project.pk, "invoice_pk": invoice.pk},
),
secure=True,
follow=True,
)
self.assertNotContains(
response, get_invoice_status_display_value(CHANGES_REQUESTED_BY_STAFF)
)

response = self.post_page(
invoice,
{
"form-submitted-change_invoice_status": "",
"status": CHANGES_REQUESTED_BY_STAFF,
"comment": "this is a comment",
},
)
self.assertEqual(response.status_code, 204)
self.assertTrue("invoicesUpdated" in response.headers.get("HX-Trigger", ""))
response = self.client.get(
reverse(
"apply:projects:partial-invoice-status",
kwargs={"pk": project.pk, "invoice_pk": invoice.pk},
),
secure=True,
follow=True,
)
self.assertContains(
response, get_invoice_status_display_value(CHANGES_REQUESTED_BY_STAFF)
)


class TestApplicantChangeInvoiceStatus(BaseViewTestCase):
base_view_name = "invoice-detail"
Expand Down

0 comments on commit 94b462f

Please sign in to comment.