Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid paying_for_college test #8711

Merged
merged 2 commits into from
Jan 10, 2025
Merged

Fix invalid paying_for_college test #8711

merged 2 commits into from
Jan 10, 2025

Conversation

chosak
Copy link
Member

@chosak chosak commented Jan 8, 2025

This test in paying_for_college isn't actually testing anything. The call to

self.assertTrue(mock_requests.called_with, unicode_endpoint.encode("utf-8"))

is invalid because mock objects don't have a called_with method, they have assert_called_with.

The existing code is asserting True against something that is always truth, namely, the new mock returned by the call to the non-existent mock_requests.called_with method. The second argument is ignored as it's treated as the msg argument in assertTrue.

This PR fixes the test by correctly calling assert_called_with and also changing the mock to patch request.post, not request.get, as that's what's called by the notification code being tested.

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code follows the standards laid out in the CFPB development guidelines

@chosak chosak requested review from higs4281 and wpears January 8, 2025 21:55
@chosak
Copy link
Member Author

chosak commented Jan 8, 2025

I notice there are a bunch of other uses of mock.called_with in the cf.gov Python tests. I will fix those in a subsequent PR.

Copy link
Member

@wpears wpears left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔎

Copy link
Member

@higs4281 higs4281 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@chosak chosak added this pull request to the merge queue Jan 10, 2025
Merged via the queue into main with commit 34e84f0 Jan 10, 2025
12 checks passed
@chosak chosak deleted the fix/pfc-notification-test branch January 10, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants