Commit f6100207 by Sheng

Changed quotes

parent 0fb6caa9
...@@ -63,35 +63,35 @@ class TestApp(AsyncHTTPTestCase): ...@@ -63,35 +63,35 @@ class TestApp(AsyncHTTPTestCase):
response = self.fetch('/') response = self.fetch('/')
self.assertEqual(response.code, 200) self.assertEqual(response.code, 200)
body = 'hostname=&port=&username=&password' body = 'hostname=&port=&username=&password'
response = self.fetch('/', method="POST", body=body) response = self.fetch('/', method='POST', body=body)
self.assertIn(b'"status": "The hostname field is required"', response.body) # noqa self.assertIn(b'"status": "The hostname field is required"', response.body) # noqa
body = 'hostname=127.0.0.1&port=&username=&password' body = 'hostname=127.0.0.1&port=&username=&password'
response = self.fetch('/', method="POST", body=body) response = self.fetch('/', method='POST', body=body)
self.assertIn(b'"status": "The port field is required"', response.body) self.assertIn(b'"status": "The port field is required"', response.body)
body = 'hostname=127.0.0.1&port=port&username=&password' body = 'hostname=127.0.0.1&port=port&username=&password'
response = self.fetch('/', method="POST", body=body) response = self.fetch('/', method='POST', body=body)
self.assertIn(b'"status": "Invalid port', response.body) self.assertIn(b'"status": "Invalid port', response.body)
body = 'hostname=127.0.0.1&port=70000&username=&password' body = 'hostname=127.0.0.1&port=70000&username=&password'
response = self.fetch('/', method="POST", body=body) response = self.fetch('/', method='POST', body=body)
self.assertIn(b'"status": "Invalid port', response.body) self.assertIn(b'"status": "Invalid port', response.body)
body = 'hostname=127.0.0.1&port=7000&username=&password' body = 'hostname=127.0.0.1&port=7000&username=&password'
response = self.fetch('/', method="POST", body=body) response = self.fetch('/', method='POST', body=body)
self.assertIn(b'"status": "The username field is required"', response.body) # noqa self.assertIn(b'"status": "The username field is required"', response.body) # noqa
def test_app_with_wrong_credentials(self): def test_app_with_wrong_credentials(self):
response = self.fetch('/') response = self.fetch('/')
self.assertEqual(response.code, 200) self.assertEqual(response.code, 200)
response = self.fetch('/', method="POST", body=self.body + 's') response = self.fetch('/', method='POST', body=self.body + 's')
self.assertIn(b'Authentication failed.', response.body) self.assertIn(b'Authentication failed.', response.body)
def test_app_with_correct_credentials(self): def test_app_with_correct_credentials(self):
response = self.fetch('/') response = self.fetch('/')
self.assertEqual(response.code, 200) self.assertEqual(response.code, 200)
response = self.fetch('/', method="POST", body=self.body) response = self.fetch('/', method='POST', body=self.body)
data = json.loads(to_str(response.body)) data = json.loads(to_str(response.body))
self.assertIsNone(data['status']) self.assertIsNone(data['status'])
self.assertIsNotNone(data['id']) self.assertIsNotNone(data['id'])
...@@ -104,7 +104,7 @@ class TestApp(AsyncHTTPTestCase): ...@@ -104,7 +104,7 @@ class TestApp(AsyncHTTPTestCase):
response = yield client.fetch(url) response = yield client.fetch(url)
self.assertEqual(response.code, 200) self.assertEqual(response.code, 200)
response = yield client.fetch(url, method="POST", body=self.body) response = yield client.fetch(url, method='POST', body=self.body)
data = json.loads(to_str(response.body)) data = json.loads(to_str(response.body))
self.assertIsNone(data['status']) self.assertIsNone(data['status'])
self.assertIsNotNone(data['id']) self.assertIsNotNone(data['id'])
...@@ -130,9 +130,9 @@ class TestApp(AsyncHTTPTestCase): ...@@ -130,9 +130,9 @@ class TestApp(AsyncHTTPTestCase):
content_type, body = encode_multipart_formdata(self.body_dict.items(), content_type, body = encode_multipart_formdata(self.body_dict.items(),
files) files)
headers = { headers = {
"Content-Type": content_type, 'content-length': str(len(body)) 'Content-Type': content_type, 'content-length': str(len(body))
} }
response = yield client.fetch(url, method="POST", headers=headers, response = yield client.fetch(url, method='POST', headers=headers,
body=body) body=body)
data = json.loads(to_str(response.body)) data = json.loads(to_str(response.body))
self.assertIsNone(data['status']) self.assertIsNone(data['status'])
...@@ -159,9 +159,9 @@ class TestApp(AsyncHTTPTestCase): ...@@ -159,9 +159,9 @@ class TestApp(AsyncHTTPTestCase):
content_type, body = encode_multipart_formdata(self.body_dict.items(), content_type, body = encode_multipart_formdata(self.body_dict.items(),
files) files)
headers = { headers = {
"Content-Type": content_type, 'content-length': str(len(body)) 'Content-Type': content_type, 'content-length': str(len(body))
} }
response = yield client.fetch(url, method="POST", headers=headers, response = yield client.fetch(url, method='POST', headers=headers,
body=body) body=body)
data = json.loads(to_str(response.body)) data = json.loads(to_str(response.body))
self.assertIsNotNone(data['status']) self.assertIsNotNone(data['status'])
...@@ -180,11 +180,11 @@ class TestApp(AsyncHTTPTestCase): ...@@ -180,11 +180,11 @@ class TestApp(AsyncHTTPTestCase):
content_type, body = encode_multipart_formdata(self.body_dict.items(), content_type, body = encode_multipart_formdata(self.body_dict.items(),
files) files)
headers = { headers = {
"Content-Type": content_type, 'content-length': str(len(body)) 'Content-Type': content_type, 'content-length': str(len(body))
} }
with self.assertRaises(HTTPError): with self.assertRaises(HTTPError):
yield client.fetch(url, method="POST", headers=headers, body=body) yield client.fetch(url, method='POST', headers=headers, body=body)
@tornado.testing.gen_test @tornado.testing.gen_test
def test_app_with_correct_credentials_user_robey(self): def test_app_with_correct_credentials_user_robey(self):
...@@ -193,7 +193,7 @@ class TestApp(AsyncHTTPTestCase): ...@@ -193,7 +193,7 @@ class TestApp(AsyncHTTPTestCase):
response = yield client.fetch(url) response = yield client.fetch(url)
self.assertEqual(response.code, 200) self.assertEqual(response.code, 200)
response = yield client.fetch(url, method="POST", body=self.body) response = yield client.fetch(url, method='POST', body=self.body)
data = json.loads(to_str(response.body)) data = json.loads(to_str(response.body))
self.assertIsNone(data['status']) self.assertIsNone(data['status'])
self.assertIsNotNone(data['id']) self.assertIsNotNone(data['id'])
...@@ -214,7 +214,7 @@ class TestApp(AsyncHTTPTestCase): ...@@ -214,7 +214,7 @@ class TestApp(AsyncHTTPTestCase):
self.assertEqual(response.code, 200) self.assertEqual(response.code, 200)
body = self.body.replace('robey', 'bar') body = self.body.replace('robey', 'bar')
response = yield client.fetch(url, method="POST", body=body) response = yield client.fetch(url, method='POST', body=body)
data = json.loads(to_str(response.body)) data = json.loads(to_str(response.body))
self.assertIsNone(data['status']) self.assertIsNone(data['status'])
self.assertIsNotNone(data['id']) self.assertIsNotNone(data['id'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment