Merge "Add get tasks, share imported image, and task states tests"
This commit is contained in:
75
cloudroast/images/v2/functional/test_get_tasks.py
Normal file
75
cloudroast/images/v2/functional/test_get_tasks.py
Normal file
@@ -0,0 +1,75 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from cafe.drivers.unittest.decorators import tags
|
||||
from cloudcafe.images.common.types import TaskTypes
|
||||
from cloudroast.images.fixtures import ImagesFixture
|
||||
|
||||
|
||||
class TestGetTasks(ImagesFixture):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestGetTasks, cls).setUpClass()
|
||||
cls.tasks = cls.images_behavior.create_new_tasks(count=4)
|
||||
|
||||
@tags(type='smoke')
|
||||
def test_get_tasks(self):
|
||||
"""
|
||||
@summary: Get tasks
|
||||
|
||||
1) Given two created tasks, get tasks
|
||||
2) Verify that the list is not empty
|
||||
3) Verify that the owner of each listed task belongs to the user
|
||||
performing the request
|
||||
4) Verify that the created tasks are in the list of tasks
|
||||
"""
|
||||
|
||||
count = 2
|
||||
created_tasks = []
|
||||
first_task = self.tasks.pop()
|
||||
second_task = self.tasks.pop()
|
||||
|
||||
get_tasks = self.images_behavior.list_tasks_pagination()
|
||||
self.assertNotEqual(len(get_tasks), 0)
|
||||
|
||||
for task in get_tasks:
|
||||
self.assertEqual(task.owner, self.user_config.tenant_id)
|
||||
if (task.id_ == first_task.id_ or task.id_ == second_task.id_):
|
||||
created_tasks.append(task)
|
||||
|
||||
self.assertEqual(len(created_tasks), count)
|
||||
|
||||
@tags(type='positive', regression='true')
|
||||
def test_get_tasks_filter_type(self):
|
||||
"""
|
||||
@summary: Get tasks with a filter of type
|
||||
|
||||
1) Given two created tasks, get tasks using the filter of 'type' set
|
||||
to 'import'
|
||||
2) Verify that the list is not empty
|
||||
3) Verify that the owner of each listed task belongs to the user
|
||||
performing the request
|
||||
4) Verify that the type of each listed task is 'import'
|
||||
"""
|
||||
|
||||
get_tasks = self.images_behavior.list_tasks_pagination(
|
||||
type_=TaskTypes.IMPORT)
|
||||
self.assertNotEqual(len(get_tasks), 0)
|
||||
|
||||
for task in get_tasks:
|
||||
self.assertEqual(task.owner, self.user_config.tenant_id)
|
||||
self.assertEqual(task.type_, TaskTypes.IMPORT)
|
||||
68
cloudroast/images/v2/functional/test_share_imported_image.py
Normal file
68
cloudroast/images/v2/functional/test_share_imported_image.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
from cafe.drivers.unittest.decorators import tags
|
||||
from cloudcafe.images.common.types import ImageMemberStatus
|
||||
from cloudroast.images.fixtures import ComputeIntegrationFixture
|
||||
|
||||
|
||||
class TestShareImportedImage(ComputeIntegrationFixture):
|
||||
|
||||
@tags(type='positive', regression='true')
|
||||
def test_share_imported_image(self):
|
||||
"""
|
||||
@summary: Share imported image
|
||||
|
||||
1) As user A, create import task
|
||||
2) As user A, from the successful import task, get image
|
||||
3) Verify that the response code is 200
|
||||
4) Verify that the response contains the correct properties
|
||||
5) As user A, add image member (user B) to image id, effectively
|
||||
sharing the image with user B
|
||||
6) Verify that the response code is 200
|
||||
7) Verify that the response contains the correct properties
|
||||
8) As user B, accept the image
|
||||
9) Verify that the response code is 200
|
||||
10) As user B, list images
|
||||
11) Verify that the image is returned
|
||||
"""
|
||||
|
||||
member_id = self.alt_user_config.tenant_id
|
||||
|
||||
task = self.images_behavior.create_new_task()
|
||||
image_id = task.result.image_id
|
||||
|
||||
response = self.images_client.get_image(image_id)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
get_image = response.entity
|
||||
|
||||
errors = self.images_behavior.validate_image(get_image)
|
||||
self.assertEqual(errors, [])
|
||||
|
||||
response = self.images_client.add_member(image_id, member_id)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
member = response.entity
|
||||
|
||||
errors = self.images_behavior.validate_image_member(
|
||||
image_id, member, member_id)
|
||||
self.assertEqual(errors, [])
|
||||
|
||||
response = self.alt_images_client.update_member(
|
||||
image_id, member_id, ImageMemberStatus.ACCEPTED)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
images = self.alt_images_behavior.list_images_pagination()
|
||||
self.assertIn(get_image, images)
|
||||
69
cloudroast/images/v2/functional/test_task_states.py
Normal file
69
cloudroast/images/v2/functional/test_task_states.py
Normal file
@@ -0,0 +1,69 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
import unittest2 as unittest
|
||||
|
||||
from cafe.drivers.unittest.decorators import tags
|
||||
from cloudcafe.images.common.types import TaskStatus, TaskTypes
|
||||
from cloudroast.images.fixtures import ImagesFixture
|
||||
|
||||
|
||||
class TestTaskStates(ImagesFixture):
|
||||
|
||||
@tags(type='positive', regression='true')
|
||||
@unittest.skip('Bug, Redmine #4226')
|
||||
def test_import_task_states(self):
|
||||
"""
|
||||
@summary: Import task states - pending, processing, success
|
||||
|
||||
1) Create task
|
||||
2) Verify that the response code is 201
|
||||
3) Verify that the status is 'pending'
|
||||
4) Get task, verify that the status changes from 'pending' to
|
||||
'processing'
|
||||
5) Get task, verify that the status changes from 'processing' to
|
||||
'success'
|
||||
6) Verify that the task's properties appear correctly
|
||||
7) Verify that a result property with image_id is returned
|
||||
8) Verify that a message property is not returned
|
||||
"""
|
||||
|
||||
input_ = {'image_properties': {},
|
||||
'import_from': self.import_from,
|
||||
'import_from_format': self.import_from_format}
|
||||
|
||||
response = self.images_client.create_task(
|
||||
input_=input_, type_=TaskTypes.IMPORT)
|
||||
self.assertEqual(response.status_code, 201)
|
||||
|
||||
task = response.entity
|
||||
|
||||
self.assertEqual(task.status, TaskStatus.PENDING)
|
||||
task = self.images_behavior.wait_for_task_status(
|
||||
task.id_, TaskStatus.PROCESSING)
|
||||
task = self.images_behavior.wait_for_task_status(
|
||||
task.id_, TaskStatus.SUCCESS)
|
||||
|
||||
errors = self.images_behavior.validate_task(task)
|
||||
if self.id_regex.match(task.result.image_id) is None:
|
||||
errors.append(self.error_msg.format(
|
||||
'image_id', not None,
|
||||
self.id_regex.match(task.result.image_id)))
|
||||
if task.message is not None:
|
||||
errors.append(self.error_msg.format(
|
||||
'message', None, task.message))
|
||||
|
||||
self.assertListEqual(errors, [])
|
||||
Reference in New Issue
Block a user