-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefer simplejson, but fall back to json
- Loading branch information
Showing
11 changed files
with
154 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
Django>=1.2.3 | ||
simplejson>=2.1.5 | ||
django-uni-form>=0.8.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
#-*- coding: utf-8 -*- | ||
|
||
from simplejson import loads | ||
try: import simplejson as json | ||
except ImportError: import json | ||
from .base import * | ||
|
||
class JSONTestCase(BaseTestCase): | ||
|
||
def test_00_email(self): | ||
client = DjangoTestClient() | ||
token = self.get_token() | ||
# Sufficient scope. | ||
response = client.get( | ||
"/api/email_json", | ||
{}, | ||
"/api/email_json", | ||
{}, | ||
HTTP_AUTHORIZATION="Bearer %s" % token) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(loads(response.content)["email"], USER_EMAIL) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(json.loads(response.content)["email"], USER_EMAIL) | ||
response = client.get( | ||
"/api/email_json?callback=foo", | ||
{}, | ||
"/api/email_json?callback=foo", | ||
{}, | ||
HTTP_AUTHORIZATION="Bearer %s" % token) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response.status_code, 200) | ||
# Remove the JSON callback. | ||
content = response.content.replace("foo(", "").replace(");", "") | ||
self.assertEqual(loads(content)["email"], USER_EMAIL) | ||
self.assertEqual(json.loads(content)["email"], USER_EMAIL) | ||
response = client.get( | ||
"/api/email_json?callback=foo", | ||
{}, | ||
"/api/email_json?callback=foo", | ||
{}, | ||
HTTP_AUTHORIZATION="Bearer !!!%s" % token) | ||
content = response.content.replace("foo(", "").replace(");", "") | ||
self.assertEqual(response.status_code, 200) | ||
self.assertTrue("error" in loads(content)) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertTrue("error" in json.loads(content)) |
Oops, something went wrong.