fix remaining broken test

This commit is contained in:
David Kennedy 2025-02-01 08:35:40 -05:00
parent 6671545c55
commit 1e280ed86e
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B

View file

@ -3243,18 +3243,21 @@ class TestPortfolioInviteNewMemberView(TestWithUser, WebTest):
} }
# Act # Act
with patch("django.contrib.messages.warning") as mock_warning: with patch("django.contrib.messages.error") as mock_error:
response = self.client.post(reverse("new-member"), data=form_data) response = self.client.post(reverse("new-member"), data=form_data)
# Assert # Assert
# assert that the send_portfolio_invitation_email called # assert that the send_portfolio_invitation_email called
mock_send_email.assert_called_once_with( mock_send_email.assert_called_once_with(
email=self.new_member_email, requestor=self.user, portfolio=self.portfolio email=self.new_member_email,
requestor=self.user,
portfolio=self.portfolio,
is_admin_invitation=False,
) )
# assert that response is a redirect to reverse("members") # assert that response is a redirect to reverse("members")
self.assertRedirects(response, reverse("members")) self.assertRedirects(response, reverse("members"))
# assert that messages contains message, "Could not send email invitation" # assert that messages contains message, "Could not send email invitation"
mock_warning.assert_called_once_with(response.wsgi_request, "Could not send portfolio email invitation.") mock_error.assert_called_once_with(response.wsgi_request, "Could not send organization invitation email.")
# assert that portfolio invitation is not created # assert that portfolio invitation is not created
self.assertFalse( self.assertFalse(
PortfolioInvitation.objects.filter(email=self.new_member_email, portfolio=self.portfolio).exists(), PortfolioInvitation.objects.filter(email=self.new_member_email, portfolio=self.portfolio).exists(),