Commit ea794b41 authored by Dionysis Grigoropoulos's avatar Dionysis Grigoropoulos Committed by Christos Stavrakakis
Browse files

Add a new function to assert success code 201

* Add assertSuccess201 function
* Use this new function in test/subnets.py
parent 3e0d4da8
......@@ -90,7 +90,7 @@ class SubnetTest(BaseAPITest):
}
response = self.post(SUBNETS_URL, test_net.userid,
json.dumps(request), "json")
self.assertSuccess(response)
self.assertSuccess201(response)
resp = json.loads(response.content)['subnet']
self.assertEqual("10.0.3.1", resp['gateway_ip'])
self.assertEqual([{"start": "10.0.3.2", "end": "10.0.3.254"}],
......@@ -109,7 +109,7 @@ class SubnetTest(BaseAPITest):
}
response = self.post(SUBNETS_URL, test_net.userid,
json.dumps(request), "json")
self.assertSuccess(response)
self.assertSuccess201(response)
def test_create_subnet_success_ipv6_with_slaac(self):
"""Test create a subnet with ipv6 and slaac"""
......@@ -123,7 +123,7 @@ class SubnetTest(BaseAPITest):
}
response = self.post(SUBNETS_URL, test_net.userid,
json.dumps(request), "json")
self.assertSuccess(response)
self.assertSuccess201(response)
resp = json.loads(response.content)['subnet']
self.assertEqual("fdc1:4992:1130:fc0b::1", resp['gateway_ip'])
self.assertEqual([], resp['allocation_pools'])
......@@ -171,7 +171,7 @@ class SubnetTest(BaseAPITest):
}
response = self.post(SUBNETS_URL, test_net.userid,
json.dumps(request), "json")
self.assertSuccess(response)
self.assertSuccess201(response)
def test_create_subnet_with_multiple_ip_pools(self):
"""Test create a subnet with multiple IP pools"""
......@@ -190,7 +190,7 @@ class SubnetTest(BaseAPITest):
}
response = self.post(SUBNETS_URL, test_net.userid,
json.dumps(request), "json")
self.assertSuccess(response)
self.assertSuccess201(response)
resp = json.loads(response.content)['subnet']
self.assertEqual([{"start": "10.0.3.2", "end": "10.0.3.100"},
{"start": "10.0.3.200", "end": "10.0.3.220"}],
......@@ -208,7 +208,7 @@ class SubnetTest(BaseAPITest):
}
response = self.post(SUBNETS_URL, test_net.userid,
json.dumps(request), "json")
self.assertSuccess(response)
self.assertSuccess201(response)
resp = json.loads(response.content)['subnet']
self.assertEqual("10.0.3.150", resp['gateway_ip'])
self.assertEqual([{"start": "10.0.3.1", "end": "10.0.3.149"},
......@@ -390,7 +390,7 @@ class SubnetTest(BaseAPITest):
}
response = self.post(SUBNETS_URL, test_net.userid, json.dumps(request),
"json")
self.assertSuccess(response)
self.assertSuccess201(response)
def test_create_subnet_with_dns_nameservers(self):
"""Create a subnet with dns nameservers"""
......@@ -403,7 +403,7 @@ class SubnetTest(BaseAPITest):
}
response = self.post(SUBNETS_URL, test_net.userid, json.dumps(request),
"json")
self.assertSuccess(response)
self.assertSuccess201(response)
def test_create_subnet_with_host_routes(self):
"""Create a subnet with dns nameservers"""
......@@ -416,7 +416,7 @@ class SubnetTest(BaseAPITest):
}
response = self.post(SUBNETS_URL, test_net.userid, json.dumps(request),
"json")
self.assertSuccess(response)
self.assertSuccess201(response)
resp = json.loads(response.content)['subnet']
self.assertEqual(["8.8.8.8", "1.1.1.1"], resp["host_routes"])
......
......@@ -247,6 +247,9 @@ class BaseAPITest(TestCase):
def assertSuccess(self, response):
self.assertTrue(response.status_code in [200, 202, 203, 204])
def assertSuccess201(self, response):
self.assertEqual(response.status_code, 201)
def assertFault(self, response, status_code, name):
self.assertEqual(response.status_code, status_code)
fault = json.loads(response.content)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment