• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python support.assert_response_code函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.support.assert_response_code函数的典型用法代码示例。如果您正苦于以下问题:Python assert_response_code函数的具体用法?Python assert_response_code怎么用?Python assert_response_code使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_response_code函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_jsonp_response_when_accept_textjavascript

 def test_jsonp_response_when_accept_textjavascript(self):
     response = self._fetch(
         self.get_url('/api/?callback=my_callback'), 'GET', headers={
             'Accept': 'text/javascript'
         })
     assert_response_code(response, 200)
     assert response.body.decode('utf-8').startswith('my_callback(')
开发者ID:Hazer,项目名称:tapioca,代码行数:7,代码来源:test_rest_api.py


示例2: test_post_to_create_a_new_resource

 def test_post_to_create_a_new_resource(self):
     a_new_item = {
         'text': 'this is my new item'
     }
     response = self.post(self.get_url('/api'), dumps(a_new_item))
     assert_response_code(response, 201)
     assert 'Location' in response.headers
开发者ID:costalince,项目名称:tapioca,代码行数:7,代码来源:test_rest_api.py


示例3: test_post_to_create_a_new_resource

 def test_post_to_create_a_new_resource(self):
     a_new_item = {
         'text': 'this is my new item'
     }
     response = self.post(self.get_url('/api'), dumps(a_new_item))
     assert_response_code(response, 201)
     self.assertRegexpMatches(response.headers['Location'], r'http://localhost:\d+/api/\d+')
     assert loads(response.body)['text'] == 'this is my new item'
开发者ID:Hazer,项目名称:tapioca,代码行数:8,代码来源:test_rest_api.py


示例4: test_show_content_as_html_when_requested_by_browser

 def test_show_content_as_html_when_requested_by_browser(self):
     CHROME_ACCEPT_HEADER = 'text/html,application/xhtml+xml,application/xm'\
                            'l;q=0.9,*/*;q=0.8'
     response = self._fetch(
         self.get_url('/api/'), 'GET', headers={
             'Accept': CHROME_ACCEPT_HEADER
         })
     assert_response_code(response, 200)
     assert '<body>' in response.body.decode('utf-8')
开发者ID:Hazer,项目名称:tapioca,代码行数:9,代码来源:test_rest_api.py


示例5: test_get_request_to_list_all_resource_instances

 def test_get_request_to_list_all_resource_instances(self):
     response = self.get('/api')
     assert_response_code(response, 200)
     resources = loads(response.body.decode('utf-8'))
     number_of_items = len(resources)
     assert number_of_items == 10, 'should return 10 resources but returned {0:d}'.format(number_of_items)
     for item in resources:
         assert 'id' in item, 'should have the key \'id\' in the resource instance'
         assert 'text' in item, 'should have the \'text\' in the resource instance'
开发者ID:Hazer,项目名称:tapioca,代码行数:9,代码来源:test_rest_api.py


示例6: test_update_new_instance_of_the_resource_with_content_type_text_xml

 def test_update_new_instance_of_the_resource_with_content_type_text_xml(self):
     an_updated_item ='<comment id="2">meu comentario</comment>'
     response = self._fetch(self.get_url('/api/2'), 'PUT', headers={'Content-Type': 'text/xml'}, body=an_updated_item)
     assert_response_code(response, 204)
     # get the resource to verify if it was updated
     response = self._fetch(response.headers['Location'], 'GET', headers={'Accept': 'text/xml'})
     assert 'text/xml' in response.headers['Content-Type'], 'the content-type should be text/xml but it was {0}'.format(response.headers['Content-Type'])
     doc = ElementTree.fromstring(response.body)
     assert doc.tag == 'comment', 'the tag should be "comment" but it was {0}'.format(doc.tag)
     assert doc.text == 'meu comentario', 'the comment text should be "meu comentario" but it was {0}'.format(doc.text)
开发者ID:Hazer,项目名称:tapioca,代码行数:10,代码来源:test_rest_api.py


示例7: test_put_to_update_an_existing_resource

 def test_put_to_update_an_existing_resource(self):
     response = self.get('/api/1')
     assert_response_code(response, 200)
     resource = loads(response.body.decode('utf-8'))
     resource['comment'] = 'wow!'
     response = self.put(self.get_url('/api/1'), dumps(resource))
     assert_response_code(response, 204)
     response = self.get('/api/1')
     resource = loads(response.body.decode('utf-8'))
     assert 'comment' in resource
     assert resource['comment'] == 'wow!'
开发者ID:Hazer,项目名称:tapioca,代码行数:11,代码来源:test_rest_api.py


示例8: test_create_new_instance_of_the_resource_with_content_type_text_xml

 def test_create_new_instance_of_the_resource_with_content_type_text_xml(self):
     a_new_item ='<comment>meu comentario</comment>'
     response = self._fetch(self.get_url('/api'), 'POST', headers={'Content-Type': 'text/xml'}, body=a_new_item)
     assert_response_code(response, 201)
     # gets the new instance
     response = self._fetch(response.headers['Location'], 'GET', headers={'Accept': 'text/xml'})
     assert 'text/xml' in response.headers['Content-Type'], 'the content-type should be text/xml but it was {0}'.format(response.headers['Content-Type'])
     doc = ElementTree.fromstring(response.body)
     assert doc.tag == 'comment', 'the tag should be "comment" but it was {0}'.format(doc.tag)
     assert doc.text == 'meu comentario', 'the comment text should be "meu comentario" but it was {0}'.format(doc.text)
     assert doc.get('id') == '10', 'the id should be 11 but it was {0}'.format(doc.get('id'))
开发者ID:Hazer,项目名称:tapioca,代码行数:11,代码来源:test_rest_api.py


示例9: test_should_raise_404_when_extension_is_not_found

 def test_should_raise_404_when_extension_is_not_found(self):
     response = self.get('/api/1.rb')
     assert_response_code(response, 404)
开发者ID:Hazer,项目名称:tapioca,代码行数:3,代码来源:test_rest_api.py


示例10: test_should_return_type_xml_as_specified_in_url

 def test_should_return_type_xml_as_specified_in_url(self):
     response = self.get('/api/1.xml')
     assert_response_code(response, 200)
     assert '</comment>' in response.body.decode('utf-8')
开发者ID:Hazer,项目名称:tapioca,代码行数:4,代码来源:test_rest_api.py


示例11: test_should_return_type_json_as_specified_in_url

 def test_should_return_type_json_as_specified_in_url(self):
     response = self.get('/api/1.json')
     assert_response_code(response, 200)
     data = loads(response.body.decode('utf-8'))
     assert 'id' in data.decode('utf-8')
开发者ID:Hazer,项目名称:tapioca,代码行数:5,代码来源:test_rest_api.py


示例12: test_get_a_resource_that_does_not_exist

 def test_get_a_resource_that_does_not_exist(self):
     response = self.get('/api/30')
     assert_response_code(response, 404)
开发者ID:Hazer,项目名称:tapioca,代码行数:3,代码来源:test_rest_api.py


示例13: test_try_to_update_a_resource

 def test_try_to_update_a_resource(self):
     response = self.put(self.get_url('/api/1'), dumps(dict(text='nice')))
     assert_response_code(response, 404)
开发者ID:Hazer,项目名称:tapioca,代码行数:3,代码来源:test_rest_api.py


示例14: test_try_to_list_resources

 def test_try_to_list_resources(self):
     response = self.get('/api')
     assert_response_code(response, 404)
开发者ID:Hazer,项目名称:tapioca,代码行数:3,代码来源:test_rest_api.py


示例15: test_should_return_with_the_callback_name_i_choose

 def test_should_return_with_the_callback_name_i_choose(self):
     response = self.get('/api/1.js?callback=fooBar')
     assert_response_code(response, 200)
     assert response.body.decode('utf-8').startswith('fooBar(')
开发者ID:Hazer,项目名称:tapioca,代码行数:4,代码来源:test_rest_api.py


示例16: test_choose_response_type_based_on_the_accept_header

 def test_choose_response_type_based_on_the_accept_header(self):
     url = self.get_url('/api/1')
     response = self._fetch(url, 'GET', headers={'Accept':'application/json, text/xml'})
     assert_response_code(response, 200)
     assert 'application/json' in response.headers['Content-Type'], 'the content-type should be application/json but it was {0}'.format(response.headers['Content-Type'])
开发者ID:Hazer,项目名称:tapioca,代码行数:5,代码来源:test_rest_api.py


示例17: test_return_resource_as_xml

 def test_return_resource_as_xml(self):
     url = self.get_url('/api/1')
     response = self._fetch(url, 'GET', headers=dict(Accept='text/xml'))
     assert_response_code(response, 200)
     assert 'text/xml' in response.headers['Content-Type'], 'the content-type should be text/xml but it was {0}'.format(response.headers['Content-Type'])
     assert response.body == b'<comment id="1">X</comment>'
开发者ID:Hazer,项目名称:tapioca,代码行数:6,代码来源:test_rest_api.py


示例18: test_delete_method_to_destroy_a_resource

 def test_delete_method_to_destroy_a_resource(self):
     response = self.delete(self.get_url('/api/1'))
     assert_response_code(response, 200)
     response = self.delete(self.get_url('/api/1'))
     assert_response_code(response, 404)
开发者ID:Hazer,项目名称:tapioca,代码行数:5,代码来源:test_rest_api.py


示例19: test_try_to_update_a_resource_that_does_not_exist

 def test_try_to_update_a_resource_that_does_not_exist(self):
     response = self.put(self.get_url('/api/30'), dumps(dict(text='not exist')))
     assert_response_code(response, 404)
开发者ID:Hazer,项目名称:tapioca,代码行数:3,代码来源:test_rest_api.py


示例20: test_should_throw_error_when_required_param_is_not_passed

 def test_should_throw_error_when_required_param_is_not_passed(self):
     response = self.get('/projects.json')
     assert_response_code(response, 400)
     assert loads(response.body)['error'] == \
         'The "ck" parameter is required.'
开发者ID:daqing15,项目名称:tapioca,代码行数:5,代码来源:test_validation.py



注:本文中的tests.support.assert_response_code函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python support.command_configure函数代码示例发布时间:2022-05-27
下一篇:
Python stetl_test_case.StetlTestCase类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap