本文整理匯總了Python中tests.Test.method方法的典型用法代碼示例。如果您正苦於以下問題:Python Test.method方法的具體用法?Python Test.method怎麽用?Python Test.method使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tests.Test
的用法示例。
在下文中一共展示了Test.method方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_patch
# 需要導入模塊: from tests import Test [as 別名]
# 或者: from tests.Test import method [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 method [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_delete
# 需要導入模塊: from tests import Test [as 別名]
# 或者: from tests.Test import method [as 別名]
def test_delete(self):
""" Try removing an item """
test = Test()
test.url = self.prefix + "/api/person/1/"
test.expected_status = [200, 202, 204]
test.method = u"DELETE"
test_response = resttest.run_test(test)
self.assertEqual(True, test_response.passed)
self.assertEqual(204, test_response.response_code)
# Verify it's really gone
test.method = u"GET"
test.expected_status = [404]
test_response = resttest.run_test(test)
self.assertEqual(True, test_response.passed)
self.assertEqual(404, test_response.response_code)
# Check it's gone by name
test2 = Test()
test2.url = self.prefix + "/api/person/?first_name__contains=Gaius"
test_response2 = resttest.run_test(test2)
self.assertTrue(test_response2.passed)
self.assertTrue(u'"objects": []' in test_response2.unicode_body())
示例4: test_post
# 需要導入模塊: from tests import Test [as 別名]
# 或者: from tests.Test import method [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))
示例5: test_put_created
# 需要導入模塊: from tests import Test [as 別名]
# 或者: from tests.Test import method [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())