Change expect_json to put parsed json in new attr - #1508
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.
When does one use _replace vs. replace?
There was a problem hiding this comment.
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. |
|
👍 |
There was a problem hiding this comment.
$.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