-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Change expect_json to put parsed json in new attr #1508
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
Conversation
|
@dmitchell Jenkins is showing test failures on this PR, but I don't know if those failures are due to your code changes or not. Can you take a look, fix if necessary, rebase onto latest master, and re-run the tests? |
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.
When does one use _replace vs. replace?
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.
For locations always use replace since chris created a method which stifles the pylint error of using an internal fn.
|
Seems like it would be a good idea to subclass the Django test client and add a new method: class AjaxEnabledTestClient(Client):
def ajax_post(self, path, data={}, content_type="application/json", **kwargs):
if not isinstance(data, basestring):
data = json.dumps(data)
kwargs.setdefault("HTTP_X_REQUESTED_WITH", "XMLHttpRequest")
return self.post(path=path, data=data, content_type=content_type, **kwargs)Then attach this subclass to the test suite as |
|
Passes all the tests now. |
|
👍 |
cms/static/coffee/src/main.coffee
Outdated
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.
$.postJSON and $["postJSON"] are exactly equivalent in Javascript, and the former is easier to read.
|
👍 |
Change expect_json to put parsed json in new attr
* Fix enrollment_date for paid course openedx#1240 * Implements ga-self-paced for Studio openedx#1240 * Implements ga-self-paced courseware openedx#1240 * Fix review
I didn't change places which aren't using expect_json to use it, but I did fix expect_json and all the unit tests afaik. It's interesting that our existing unit tests were avoiding the json serialization deserialization by never using "application/json" for the ACCEPT but instead using "multipart/form"
@singingwolfboy @cahrens please review