本文整理汇总了Python中tests.Test.headers方法的典型用法代码示例。如果您正苦于以下问题:Python Test.headers方法的具体用法?Python Test.headers怎么用?Python Test.headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.Test
的用法示例。
在下文中一共展示了Test.headers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_patch
# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import headers [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)
示例2: test_put_inplace
# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import headers [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)
示例3: test_post
# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import headers [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))
示例4: test_put_created
# 需要导入模块: from tests import Test [as 别名]
# 或者: from tests.Test import headers [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())