summaryrefslogtreecommitdiffstats
path: root/snaps/tests/file_utils_tests.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-08-17 15:21:37 -0600
committerSteven Pisarski <s.pisarski@cablelabs.com>2017-08-24 21:12:02 +0000
commit1342eb17df248ec75cc57e9c380a7753fc432194 (patch)
tree72a3b065394b7bcaaddb801e3321edc1ba4b8818 /snaps/tests/file_utils_tests.py
parent49aaa5d61e87e11c5d5b9ce7dd2fa598f16b82a7 (diff)
Added method to return OpenStackVmInstance from Heat.
OpenStackHeatStack now can introspect the VMs that the template was responsible for deploying and return an instanitated instance of OpenStackVmInstance for each VM deployed. When the VM has a Floating IP, these instances have the ability to connect via SSH just like one created from scratch. JIRA: SNAPS-172 Change-Id: I5a7ed3a09bb871afc55c718aa80a9069b1eb4da7 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/tests/file_utils_tests.py')
-rw-r--r--snaps/tests/file_utils_tests.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/snaps/tests/file_utils_tests.py b/snaps/tests/file_utils_tests.py
index ef8b4ae..befe37a 100644
--- a/snaps/tests/file_utils_tests.py
+++ b/snaps/tests/file_utils_tests.py
@@ -38,8 +38,6 @@ class FileUtilsTests(unittest.TestCase):
self.tmpFile = self.test_dir + '/bar.txt'
self.tmp_file_opened = None
- if not os.path.exists(self.tmpFile):
- self.tmp_file_opened = open(self.tmpFile, 'wb')
def tearDown(self):
if self.tmp_file_opened:
@@ -70,6 +68,9 @@ class FileUtilsTests(unittest.TestCase):
directory
"""
if not os.path.exists(self.tmpFile):
+ self.tmp_file_opened = open(self.tmpFile, 'wb')
+
+ if not os.path.exists(self.tmpFile):
os.makedirs(self.tmpFile)
result = file_utils.file_exists(self.tmpFile)
@@ -115,3 +116,20 @@ class FileUtilsTests(unittest.TestCase):
self.assertEqual('http://foo:5000/v2.0/', os_env_dict['OS_AUTH_URL'])
self.assertEqual('admin', os_env_dict['OS_USERNAME'])
self.assertEqual('admin', os_env_dict['OS_TENANT_NAME'])
+
+ def test_write_str_to_file(self):
+ """
+ Ensure the file_utils.fileExists() method returns false with a
+ directory
+ """
+ test_val = 'test string'
+
+ test_file = file_utils.save_string_to_file(
+ test_val, self.tmpFile)
+ result1 = file_utils.file_exists(self.tmpFile)
+ self.assertTrue(result1)
+ result2 = file_utils.file_exists(test_file.name)
+ self.assertTrue(result2)
+
+ file_contents = file_utils.read_file(self.tmpFile)
+ self.assertEqual(test_val, file_contents)