当前位置: 首页>>代码示例>>Python>>正文


Python Test.body方法代码示例

本文整理汇总了Python中tests.Test.body方法的典型用法代码示例。如果您正苦于以下问题:Python Test.body方法的具体用法?Python Test.body怎么用?Python Test.body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.Test的用法示例。


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

示例1: test_patch

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import body [as 别名]
 def test_patch(self):
     """ Basic local get test """
     test = Test()
     test.url = self.prefix + "/api/person/2/"
     test.method = "PATCH"
     test.body = '{"login":"special"}'
     test.headers = {u"Content-Type": u"application/json", u"X-HTTP-Method-Override": u"PATCH"}
     test.expected_status = [202, 400]  # Django issues give a 400, sigh
     test_response = resttest.run_test(test)
     self.assertTrue(test_response.passed)
开发者ID:pbkhrv,项目名称:pyresttest,代码行数:12,代码来源:functionaltest.py

示例2: test_put_inplace

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import body [as 别名]
 def test_put_inplace(self):
     """ Test PUT where item already exists """
     test = Test()
     test.url = self.prefix + "/api/person/1/"
     test.method = u"PUT"
     test.body = '{"first_name": "Gaius","id": 1,"last_name": "Baltar","login": "gbaltar"}'
     test.headers = {u"Content-Type": u"application/json"}
     test_response = resttest.run_test(test)
     self.assertEqual(True, test_response.passed)
     self.assertEqual(200, test_response.response_code)
开发者ID:pbkhrv,项目名称:pyresttest,代码行数:12,代码来源:functionaltest.py

示例3: test_post

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import body [as 别名]
    def test_post(self):
        """ Test POST to create an item """
        test = Test()
        test.url = self.prefix + "/api/person/"
        test.method = u"POST"
        test.expected_status = [200, 201, 204]
        test.body = '{"first_name": "Willim","last_name": "Adama","login": "theadmiral"}'
        test.headers = {u"Content-Type": u"application/json"}
        test_response = resttest.run_test(test)
        self.assertEqual(True, test_response.passed)
        self.assertEqual(201, test_response.response_code)

        # Test user was created
        test2 = Test()
        test2.url = self.prefix + "/api/person/?login=theadmiral"
        test_response2 = resttest.run_test(test2)
        self.assertTrue(test_response2.passed)
        obj = json.loads(str(test_response2.body))
        print(json.dumps(obj))
开发者ID:pbkhrv,项目名称:pyresttest,代码行数:21,代码来源:functionaltest.py

示例4: test_put_created

# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import body [as 别名]
    def test_put_created(self):
        """ Test PUT where item DOES NOT already exist """
        test = Test()
        test.url = self.prefix + "/api/person/100/"
        test.method = u"PUT"
        test.expected_status = [200, 201, 204]
        test.body = '{"first_name": "Willim","last_name": "Adama","login":"theadmiral", "id": 100}'
        test.headers = {u"Content-Type": u"application/json"}
        test_response = resttest.run_test(test)
        self.assertEqual(True, test_response.passed)
        self.assertEqual(201, test_response.response_code)

        # Test it was actually created
        test2 = Test()
        test2.url = test.url
        test_response2 = resttest.run_test(test2)
        self.assertTrue(test_response2.passed)
        self.assertTrue(u'"last_name": "Adama"' in test_response2.unicode_body())
        self.assertTrue(u'"login": "theadmiral"' in test_response2.unicode_body())
开发者ID:pbkhrv,项目名称:pyresttest,代码行数:21,代码来源:functionaltest.py


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