mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-23 20:06:35 +11:00
Python 3 compatibility.
This commit is contained in:
parent
d14bde889f
commit
43f82ba42b
2 changed files with 14 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
||||||
language: python
|
language: python
|
||||||
python:
|
python:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
|
- "3.3"
|
||||||
install:
|
install:
|
||||||
- "pip install -r requirements.txt"
|
- "pip install -r requirements.txt"
|
||||||
- "pip install -e ."
|
- "pip install -e ."
|
||||||
|
|
|
@ -51,17 +51,18 @@ class SnippetAPITestCase(TestCase):
|
||||||
data = {'content': u"Hello Wörld.\n\tGood Bye"}
|
data = {'content': u"Hello Wörld.\n\tGood Bye"}
|
||||||
|
|
||||||
response = self.client.post(self.api_url, data)
|
response = self.client.post(self.api_url, data)
|
||||||
|
content = response.content.decode('utf-8')
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(Snippet.objects.count(), 1)
|
self.assertEqual(Snippet.objects.count(), 1)
|
||||||
|
|
||||||
# The response is a URL with quotes
|
# The response is a URL with quotes
|
||||||
self.assertTrue(response.content.startswith('"'))
|
self.assertTrue(content.startswith('"'))
|
||||||
self.assertTrue(response.content.endswith('"'))
|
self.assertTrue(content.endswith('"'))
|
||||||
|
|
||||||
# The URL returned is the absolute url to the snippet.
|
# The URL returned is the absolute url to the snippet.
|
||||||
# If we call that url our snippet should be in the page content.
|
# If we call that url our snippet should be in the page content.
|
||||||
snippet_url = response.content[1:-1]
|
response = self.client.get(content[1:-1])
|
||||||
response = self.client.get(snippet_url)
|
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertContains(response, data['content'])
|
self.assertContains(response, data['content'])
|
||||||
|
@ -73,12 +74,14 @@ class SnippetAPITestCase(TestCase):
|
||||||
data = {'content': u"Hello Wörld.\n\tGood Bye", 'format': 'url'}
|
data = {'content': u"Hello Wörld.\n\tGood Bye", 'format': 'url'}
|
||||||
|
|
||||||
response = self.client.post(self.api_url, data)
|
response = self.client.post(self.api_url, data)
|
||||||
|
content = response.content.decode('utf-8')
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(Snippet.objects.count(), 1)
|
self.assertEqual(Snippet.objects.count(), 1)
|
||||||
|
|
||||||
# Response is just the link starting with http(s) and ends with a linebreak
|
# Response is just the link starting with http(s) and ends with a linebreak
|
||||||
self.assertTrue(response.content.startswith('http'))
|
self.assertTrue(content.startswith('http'))
|
||||||
self.assertTrue(response.content.endswith('\n'))
|
self.assertTrue(content.endswith('\n'))
|
||||||
|
|
||||||
|
|
||||||
def test_json_format(self):
|
def test_json_format(self):
|
||||||
|
@ -92,11 +95,13 @@ class SnippetAPITestCase(TestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
response = self.client.post(self.api_url, data)
|
response = self.client.post(self.api_url, data)
|
||||||
|
content = response.content.decode('utf-8')
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertEqual(Snippet.objects.count(), 1)
|
self.assertEqual(Snippet.objects.count(), 1)
|
||||||
|
|
||||||
from json import loads
|
from json import loads
|
||||||
json_data = loads(response.content)
|
json_data = loads(content)
|
||||||
|
|
||||||
# Response is valid json, containing, content, lexer and url
|
# Response is valid json, containing, content, lexer and url
|
||||||
self.assertEqual(json_data['content'], data['content'])
|
self.assertEqual(json_data['content'], data['content'])
|
||||||
|
|
Loading…
Reference in a new issue