Update images behaviors

*Removed read_data_file method as it's no longer required
*Added url_addition to list_all_images method
*Updated list_all_images method to utilize limit parameter
*Added check for virtual_size to validate_image method
*Updated elif to else in the create_new_task method
*Updated list_all_tasks method to utilize limit parameter
*Added description of url_addition to doc string

Change-Id: I43d8032a51b4be40efe3e846d36298b9f36f11e7
This commit is contained in:
Luke Wollney 2015-05-05 12:00:58 -05:00
parent 2dc1147347
commit dccdb4dead

View File

@ -40,23 +40,6 @@ class ImagesBehaviors(BaseBehavior):
self.client = images_client
self.resources = ResourcePool()
@staticmethod
def read_data_file(file_path):
"""
@summary: Retrieve data file for a given file path
@param file_path: Location of data file
@type file_path: String
@return: Test_data
@rtype: String
"""
with open(file_path, 'r') as DATA:
test_data = DATA.read().rstrip()
return test_data
@staticmethod
def get_comparison_data(data_file):
"""
@ -312,11 +295,14 @@ class ImagesBehaviors(BaseBehavior):
return image_list
def list_all_images(self, **params):
def list_all_images(self, url_addition=None, **params):
"""
@summary: Retrieve a complete list of images accounting for any
query parameters
@param url_addition: Additional text to be added to the end of the url
to account for duplicate sort parameters
@type url_addition: String
@param params: Parameters to alter the returned list of images
@type params: Dictionary
@ -326,8 +312,9 @@ class ImagesBehaviors(BaseBehavior):
image_list = []
results_limit = self.config.results_limit
params.update({'limit': results_limit})
resp = self.client.list_images(params)
resp = self.client.list_images(params, url_addition)
images = self.verify_resp(resp, 'list images')
while len(images) == results_limit:
@ -336,7 +323,7 @@ class ImagesBehaviors(BaseBehavior):
marker = images[results_limit - 1].id_
params.update({'marker': marker})
resp = self.client.list_images(params)
resp = self.client.list_images(params, url_addition)
images = self.verify_resp(resp, 'list images')
image_list += images
@ -426,6 +413,9 @@ class ImagesBehaviors(BaseBehavior):
if image.user_id is None:
errors.append(Messages.PROPERTY_MSG.format(
'user_id', 'not None', image.user_id))
if image.virtual_size is not None:
errors.append(Messages.PROPERTY_MSG.format(
'virtual_size', 'None', image.virtual_size))
if image.visibility is None:
errors.append(Messages.PROPERTY_MSG.format(
'visibility', 'not None', image.visibility))
@ -535,7 +525,7 @@ class ImagesBehaviors(BaseBehavior):
if type_ == TaskTypes.IMPORT:
resp = self.client.task_to_import_image(input_=input_,
type_=type_)
elif type_ == TaskTypes.EXPORT:
else:
resp = self.client.task_to_export_image(input_=input_,
type_=type_)
task = resp.entity
@ -591,6 +581,7 @@ class ImagesBehaviors(BaseBehavior):
task_list = []
results_limit = self.config.results_limit
params.update({'limit': results_limit})
resp = self.client.list_tasks(params)
tasks = self.verify_resp(resp, 'list tasks')
@ -792,6 +783,7 @@ class ImagesBehaviors(BaseBehavior):
error_statuses = [TaskStatus.FAILURE]
else:
error_statuses = [TaskStatus.SUCCESS]
verifier.add_state(
expected_statuses=[TaskStatus.PENDING],
acceptable_statuses=[TaskStatus.PROCESSING, final_status],
@ -802,6 +794,7 @@ class ImagesBehaviors(BaseBehavior):
error_statuses = [TaskStatus.PENDING, TaskStatus.FAILURE]
else:
error_statuses = [TaskStatus.PENDING, TaskStatus.SUCCESS]
verifier.add_state(
expected_statuses=[TaskStatus.PROCESSING],
acceptable_statuses=[final_status],