-
Notifications
You must be signed in to change notification settings - Fork 27
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 test when using locale middleware #300
Conversation
reverse('disclosures:pfc-feedback'), | ||
data=self.feedback_post_data) | ||
self.assertTrue(mock_render.call_count == 1) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertTrue(mock_feedback.call_count == 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine. One minor suggestion: this test seems to be testing that the Feedback
constructor is called when this view is POST
ed to. This seems a bit specific, for example the view might create the feedback object in some other way (e.g. Feedback.objects.create(...)
). It might be more clarifying to rename this test slightly more specifically (like test_feedback_post_creates_feedback
) and then do something like self.assertFalse(Feedback.objects.exists())
before and then self.assertTrue(Feedback.objects.exists())
after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@willbarton I join you in not being entirely sure of the author's intent, but test_feedback_post_creates_feedback
seems clearer in this context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't #299 make a handsome pairing for a release? |
When running the college-costs tests with https://github.com/cfpb/cfgov-refresh/, the django locale middleware is loaded. That middleware chokes trying to modify the headers of the original MagicMock it got instead of a Response object. This PR removes the mocking of
render_to_response
and mocks the feedback object creation instead.Part of GHE/CFGOV/platform/issues/798
Changes
Testing
pip install git+https://https://github.com/cfpb/college-costs.git@holistic-tests
tox -e optional
Checklist