Files
python-barbicanclient/functionaltests/cli/v1/smoke/test_container.py
Steve Heyman 8f1e12eabf Add CLI smoke functional tests for containers
Added tests and behaviors for containers.  Also refactored the
PrettyTable parsing to make it more generic so we can use it with
more than just secrets.

Change-Id: Icf3a462d6f24ce887977c07ed310b39c9d928a29
2015-05-12 12:58:14 -05:00

70 lines
2.8 KiB
Python

# Copyright (c) 2015 Rackspace, Inc.
#
# 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 functionaltests.cli.base import CmdLineTestCase
from functionaltests.cli.v1.behaviors import container_behaviors
from functionaltests.cli.v1.behaviors import secret_behaviors
from testtools import testcase
class ContainerTestCase(CmdLineTestCase):
def setUp(self):
super(ContainerTestCase, self).setUp()
self.secret_behaviors = secret_behaviors.SecretBehaviors()
self.container_behaviors = container_behaviors.ContainerBehaviors()
def tearDown(self):
super(ContainerTestCase, self).tearDown()
self.container_behaviors.delete_all_created_containers()
@testcase.attr('positive')
def test_container_create(self):
secret_href = self.secret_behaviors.store_secret()
container_href = self.container_behaviors.create_container(
secret_hrefs=[secret_href])
self.assertIsNotNone(container_href)
container = self.container_behaviors.get_container(container_href)
self.assertEqual(container_href, container['Container href'])
@testcase.attr('positive')
def test_container_list(self):
containers_to_create = 10
for _ in range(containers_to_create):
secret_href = self.secret_behaviors.store_secret()
self.container_behaviors.create_container(
secret_hrefs=[secret_href])
container_list = self.container_behaviors.list_containers()
self.assertGreaterEqual(len(container_list), containers_to_create)
@testcase.attr('positive')
def test_container_delete(self):
secret_href = self.secret_behaviors.store_secret()
container_href = self.container_behaviors.create_container(
secret_hrefs=[secret_href])
self.container_behaviors.delete_container(container_href)
container = self.container_behaviors.get_container(container_href)
self.assertFalse(container)
@testcase.attr('positive')
def test_container_get(self):
secret_href = self.secret_behaviors.store_secret()
container_href = self.container_behaviors.create_container(
secret_hrefs=[secret_href])
container = self.container_behaviors.get_container(container_href)
self.assertIsNotNone(container)