Fix failing tests

This patch fixes tests failing due to,
1. project_id not present in service url.
2. updates regex for href string format.
3. uses unique domain name per test.

Change-Id: I538208e4d76d98b1426dd293fd93670e7801fc92
This commit is contained in:
Malini Kamalambal 2015-01-03 15:29:03 -05:00
parent 6f90e793da
commit 4939d2a533
3 changed files with 14 additions and 51 deletions

View File

@ -1,9 +0,0 @@
{
"www.mywebsite.com" : "www.mywebsite.com",
"www.mywebsite.co.nz" : "www.mywebsite.co.nz",
"www.mywebsite.gov.au" : "www.mywebsite.gov.au",
"mywebsite.com" : "mywebsite.com",
"mywebsite.io" : "mywebsite.io",
"mywebsite.co.uk" : "mywebsite.co.uk",
"www.mywebsite.co.uk" : "www.mywebsite.co.uk"
}

View File

@ -16,10 +16,6 @@
# limitations under the License.
import time
try:
import urllib.parse as urlparse
except ImportError:
import urlparse
import uuid
import ddt
@ -55,6 +51,8 @@ class TestCreateService(providers.TestProviderBase):
def test_create_service_positive(self, test_data):
domain_list = test_data['domain_list']
for item in domain_list:
item['domain'] = str(uuid.uuid1()) + '.com'
origin_list = test_data['origin_list']
caching_list = test_data['caching_list']
flavor_id = self.flavor_id
@ -334,30 +332,22 @@ class TestServiceActions(base.TestBase):
resp = self.client.delete_service(location=self.service_url)
self.assertEqual(resp.status_code, 202)
# As is, the service is still available in the DB till deleted from
# the provider. The test should be able to handle this with
# exponential sleep or whatever(!).
status_code = 0
count = 0
while (count < 5):
start_time = int(time.time())
stop_time = start_time + self.test_config.status_check_retry_timeout
current_status = 0
expected_status = 404
while (current_status != expected_status):
service_deleted = self.client.get_service(
location=self.service_url)
status_code = service_deleted.status_code
if status_code == 200:
time.sleep(1)
else:
current_status = service_deleted.status_code
current_time = int(time.time())
if current_time > stop_time:
break
count = count + 1
self.assertEqual(404, status_code)
self.assertEqual(404, current_status)
def test_delete_non_existing_service(self):
parsed_url = urlparse.urlparse(self.service_url)
url = "{0}://{1}{2}{3}".format(parsed_url.scheme,
parsed_url.netloc,
'/v1.0/services/',
uuid.uuid4())
url = self.service_url.rsplit('/', 1)[0] + str(uuid.uuid4())
resp = self.client.delete_service(location=url)
self.assertEqual(resp.status_code, 404)
@ -367,20 +357,6 @@ class TestServiceActions(base.TestBase):
# Placeholder till we figure out how to create provider side failure.
pass
@ddt.file_data('data_get_service_by_name.json')
def test_get_service_by_name(self, value):
resp = self.client.create_service(service_name=value,
domain_list=self.domain_list,
origin_list=self.origin_list,
caching_list=self.caching_list,
flavor_id=self.flavor_id)
self.assertEqual(resp.status_code, 202)
url = resp.headers["location"]
resp = self.client.get_service(location=url)
self.assertEqual(resp.status_code, 200)
def test_get_service(self):
resp = self.client.get_service(location=self.service_url)
self.assertEqual(resp.status_code, 200)
@ -399,11 +375,7 @@ class TestServiceActions(base.TestBase):
self.assertEqual(body['flavor_id'], self.flavor_id)
def test_get_non_existing_service(self):
parsed_url = urlparse.urlparse(self.service_url)
url = "{0}://{1}{2}{3}".format(parsed_url.scheme,
parsed_url.netloc,
'/v1.0/services/',
uuid.uuid4())
url = self.service_url.rsplit('/', 1)[0] + str(uuid.uuid4())
resp = self.client.get_service(location=url)
self.assertEqual(resp.status_code, 404)

View File

@ -59,7 +59,7 @@ error_message = {'type': 'object',
restrictions = {'type': 'array'}
flavor_id = {'type': 'string', 'pattern': '([a-zA-Z0-9_\-]{1,256})'}
service_name = {'type': 'string', 'pattern': '([a-zA-Z0-9_\-\.]{1,256})'}
uuid4 = '^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$' # noqa
uuid4 = '([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})' # noqa
service_id = {'type': 'string', 'pattern': uuid4}
# Response Schema Definition for Get Service API