summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/tests/create_stack_tests.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-06-07 14:56:00 -0600
committerspisarski <s.pisarski@cablelabs.com>2017-06-07 14:56:00 -0600
commit95d35a166fc66944fb0fc6091f4b84568aef0e7d (patch)
tree5ad804fe917c7c7a2bcf99ad285159ea0f29d015 /snaps/openstack/tests/create_stack_tests.py
parentc8212122569c2dbf6290b43a0fbde0171c2ffdc5 (diff)
Removed current working directory logic retrieving test file resources.
Some of the SNAPS tests leverage file resources contained within the project. These resources were being accessed via relative paths which required the test clients to ensure that the CWD was the <repo>/snaps directory. Replaced that logic to leverage the import pkg_resources making the tests much more flexible and robust. JIRA: SNAPS-89 Change-Id: Ic9c429ee53e4dd785641e11e1ed4de5aeeab54d1 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/tests/create_stack_tests.py')
-rw-r--r--snaps/openstack/tests/create_stack_tests.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/snaps/openstack/tests/create_stack_tests.py b/snaps/openstack/tests/create_stack_tests.py
index fa75475..bee1340 100644
--- a/snaps/openstack/tests/create_stack_tests.py
+++ b/snaps/openstack/tests/create_stack_tests.py
@@ -12,6 +12,7 @@
# 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 pkg_resources
import time
from heatclient.exc import HTTPBadRequest
@@ -145,12 +146,17 @@ class CreateStackSuccessTests(OSIntegrationTestCase):
self.env_values = {'image_name': self.image_creator.image_settings.name,
'flavor_name': self.flavor_creator.flavor_settings.name}
+ self.heat_tmplt_path = pkg_resources.resource_filename('examples.heat', 'test_heat_template.yaml')
+
def tearDown(self):
"""
Cleans the stack and downloaded stack file
"""
if self.stack_creator:
- self.stack_creator.clean()
+ try:
+ self.stack_creator.clean()
+ except:
+ pass
if self.image_creator:
try:
@@ -173,7 +179,7 @@ class CreateStackSuccessTests(OSIntegrationTestCase):
# Create Stack
# Set the default stack settings, then set any custom parameters sent from the app
stack_settings = StackSettings(name=self.__class__.__name__ + '-' + str(self.guid) + '-stack',
- template_path='../examples/heat/test_heat_template.yaml',
+ template_path=self.heat_tmplt_path,
env_values=self.env_values)
self.stack_creator = create_stack.OpenStackHeatStack(self.os_creds, stack_settings)
created_stack = self.stack_creator.create()
@@ -193,7 +199,7 @@ class CreateStackSuccessTests(OSIntegrationTestCase):
# Create Stack
# Set the default stack settings, then set any custom parameters sent from the app
template_dict = heat_utils.parse_heat_template_str(
- file_utils.read_file('../examples/heat/test_heat_template.yaml'))
+ file_utils.read_file(self.heat_tmplt_path))
stack_settings = StackSettings(name=self.__class__.__name__ + '-' + str(self.guid) + '-stack',
template=template_dict,
env_values=self.env_values)
@@ -214,7 +220,7 @@ class CreateStackSuccessTests(OSIntegrationTestCase):
"""
# Create Stack
template_dict = heat_utils.parse_heat_template_str(
- file_utils.read_file('../examples/heat/test_heat_template.yaml'))
+ file_utils.read_file(self.heat_tmplt_path))
stack_settings = StackSettings(name=self.__class__.__name__ + '-' + str(self.guid) + '-stack',
template=template_dict,
env_values=self.env_values)
@@ -253,7 +259,7 @@ class CreateStackSuccessTests(OSIntegrationTestCase):
"""
# Create Stack
template_dict = heat_utils.parse_heat_template_str(
- file_utils.read_file('../examples/heat/test_heat_template.yaml'))
+ file_utils.read_file(self.heat_tmplt_path))
stack_settings = StackSettings(name=self.__class__.__name__ + '-' + str(self.guid) + '-stack',
template=template_dict,
env_values=self.env_values)
@@ -283,6 +289,7 @@ class CreateStackNegativeTests(OSIntegrationTestCase):
self.stack_name = self.__class__.__name__ + '-' + str(uuid.uuid4())
self.stack_creator = None
+ self.heat_tmplt_path = pkg_resources.resource_filename('examples.heat', 'test_heat_template.yaml')
def tearDown(self):
if self.stack_creator:
@@ -293,7 +300,7 @@ class CreateStackNegativeTests(OSIntegrationTestCase):
"""
Expect an StackCreationError when the stack file does not exist
"""
- stack_settings = StackSettings(name=self.stack_name, template_path='../examples/heat/test_heat_template.yaml')
+ stack_settings = StackSettings(name=self.stack_name, template_path=self.heat_tmplt_path)
self.stack_creator = create_stack.OpenStackHeatStack(self.os_creds, stack_settings)
with self.assertRaises(HTTPBadRequest):
self.stack_creator.create()