def test_parse_response(self): """ Should parse requests response. """ params = {'message': 'foo'} headers = {'content-type': 'application/json'} req = self.create_request(url='http://localhost:5000/', method='POST', data=params, headers=headers) res = self.send(req, params, 'data/post.json') self.autodoc.parse('POST /', res) var = { 'describe': 'POST /', 'describe_separators': '======', 'target_url': 'http://localhost:5000/', 'status_code': 200, 'request': 'POST /', 'response_body': '{\n "response": "create"\n}', 'response_content_type': 'application/json', 'params': '{\n "message": "foo"\n}' } for k, v in iteritems(self.autodoc.vars[0]): self.assertEqual(v, var[k]) self.autodoc.clear()
def test_parse_response(self): """ Should parse WebTest response. """ res = self.client.post_json('/', params={'message': 'foo'}) autodoc.parse('POST /', res) var = { 'describe': 'POST /', 'describe_separators': '======', 'target_url': 'http://localhost:80', 'status_code': 200, 'request': 'POST /', 'response_body': '{\n "response": "create"\n}', 'response_content_type': 'application/json', 'params': '{\n "message": "foo"\n}' } for k, v in iteritems(autodoc.vars[0]): self.assertEqual(v, var[k]) autodoc.clear()
def test_should_change_separators(self): """ Should change separators. """ res = self.client.get('/') autodoc.separators = '*' autodoc.parse('GET /', res) var = { 'response_content_type': 'application/json', 'response_body': '{\n "response": "index"\n}', 'describe': 'GET /', 'request': 'GET /', 'params': '', 'status_code': 200, 'target_url': 'http://localhost:80', 'describe_separators': '*****' } for k, v in iteritems(autodoc.vars[0]): self.assertEqual(v, var[k]) autodoc.clear()
def test_should_change_separators(self): """ Should change separators. """ headers = {'content-type': 'application/json'} req = self.create_request(url='http://localhost:5000/', method='GET', headers=headers) res = self.send(req, '', 'data/get.json') self.autodoc.separators = '*' self.autodoc.parse('GET /', res) var = { 'response_content_type': 'application/json', 'response_body': '{\n "response": "index"\n}', 'describe': 'GET /', 'request': 'GET /', 'params': '', 'status_code': 200, 'target_url': 'http://localhost:5000/', 'describe_separators': '*****' } for k, v in iteritems(self.autodoc.vars[0]): self.assertEqual(v, var[k]) self.autodoc.clear()