def test_jsonp_false(self): """ Response body should not contains any callback when jsonp is false. """ client = self._create_client('jsonp_false.json') res = client.get('/user') data = self._read_json('user_get.json') self.assertEqual(to_unicode(res.data), data)
def test_jsonp_true_callback(self): """ Response body should contain callback() when jsonp option is true. """ client = self._create_client('jsonp_true.json') res = client.get('/user?callback=callback') data = self._read_json('user_get.json') self.assertEqual(to_unicode(res.data), 'callback({0})'.format(data))
def test_put_request_remapped(self): """ PUT /user/<userid> should serve userid_put.json. """ client = self._create_client('basic.json') res = client.put('/user/1') expected = self._read_json('basic/user/userid_put.json') self.assertEqual(to_unicode(res.data), expected)
def test_patch_request(self): """ PATCH /user should serve user_put.json """ client = self._create_client('basic.json') res = client.patch('/user') expected = self._read_json('basic/user_patch.json') self.assertEqual(to_unicode(res.data), expected)
def test_head_request(self): """ HEAD /user should serve empty body. """ client = self._create_client('basic.json') res = client.head('/user') self.assertEqual(to_unicode(res.data), '')
def test_delete_request(self): """ DELETE /user should serve user_put.json """ client = self._create_client('basic.json') res = client.delete('/user') expected = self._read_json('basic/user_delete.json') self.assertEqual(to_unicode(res.data), expected)
def test_get_request(self): """ GET /user should serve user_get.json """ client = self._create_client('basic.json') res = client.get('/user') expected = self._read_json('basic/user_get.json') self.assertEqual(to_unicode(res.data), expected)
def test_variable_assign_to_response_file(self): """ Variables should assign to response body. """ client = self._create_client('template.json') res = client.get('/template') text = json.loads(to_unicode(res.data))['server'] self.assertEqual(text, 'http://example.com')
def test_url_var_assign_to_response_file(self): """ Routes /<userid> url vars should assing to response body. """ client = self._create_client('template.json') res = client.get('/foo') text = json.loads(to_unicode(res.data))['message'] self.assertEqual(text, 'foo')