summaryrefslogtreecommitdiff
path: root/heat_cfntools/tests
diff options
context:
space:
mode:
authorAnant Patil <anant.patil@hp.com>2015-08-11 10:00:55 +0530
committerAnant Patil <anant.patil@hp.com>2015-08-14 12:38:13 +0530
commit20049ea85f675a86d44ed823caf23aa8cdafa173 (patch)
tree447ad5c58d44b7a6486cd463ee8f521277f6535a /heat_cfntools/tests
parentc4c50583c89af2ecc04faf6c3932f29c5dc60e50 (diff)
downloadheat-cfntools-20049ea85f675a86d44ed823caf23aa8cdafa173.tar.gz
Fix unit tests
Fix failing tests. Co-Authored-By: Sirushti Murugesan <sirushti.murugesan@hp.com> Change-Id: If44ea49e5d6262f6e6b51dfdfb76754fb7c467d5
Diffstat (limited to 'heat_cfntools/tests')
-rw-r--r--heat_cfntools/tests/test_cfn_helper.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/heat_cfntools/tests/test_cfn_helper.py b/heat_cfntools/tests/test_cfn_helper.py
index 64631f8..59020e2 100644
--- a/heat_cfntools/tests/test_cfn_helper.py
+++ b/heat_cfntools/tests/test_cfn_helper.py
@@ -1129,7 +1129,7 @@ class TestMetadataRetrieve(testtools.TestCase):
with mock.patch.object(md, 'get_nova_meta') as mock_method:
mock_method.return_value = md_data
tags = md.get_tags()
- mock_method.assert_run_with_once()
+ mock_method.assert_called_once_with()
self.assertEqual(tags_expect, tags)
@@ -1147,7 +1147,7 @@ class TestMetadataRetrieve(testtools.TestCase):
with mock.patch.object(md, 'get_nova_meta') as mock_method:
mock_method.return_value = md_data
self.assertEqual(md.get_instance_id(), uuid)
- mock_method.assert_run_with_once()
+ mock_method.assert_called_once_with()
class TestCfnInit(testtools.TestCase):
@@ -1226,21 +1226,33 @@ class TestSourcesHandler(testtools.TestCase):
sh = cfn_helper.SourcesHandler(sources)
sh.apply_sources()
mock_popen.assert_has_calls(calls)
- mock_mkdtemp.assert_run_with()
+ mock_mkdtemp.assert_called_with()
def test_apply_sources_github(self):
url = "https://github.com/NoSuchProject/tarball/NoSuchTarball"
- td = tempfile.mkdtemp()
- self.addCleanup(os.rmdir, td)
- end_file = '%s/NoSuchProject-NoSuchTarball.tar.gz' % td
- self._test_apply_sources(url, end_file)
+ dest = tempfile.mkdtemp()
+ self.addCleanup(os.rmdir, dest)
+ sources = {dest: url}
+ er = "mkdir -p '%s'; cd '%s'; curl -s '%s' | gunzip | tar -xvf -"
+ calls = popen_root_calls([er % (dest, dest, url)])
+ with mock.patch('subprocess.Popen') as mock_popen:
+ mock_popen.return_value = FakePOpen('Curl good')
+ sh = cfn_helper.SourcesHandler(sources)
+ sh.apply_sources()
+ mock_popen.assert_has_calls(calls)
def test_apply_sources_general(self):
url = "https://website.no.existe/a/b/c/file.tar.gz"
- td = tempfile.mkdtemp()
- self.addCleanup(os.rmdir, td)
- end_file = '%s/file.tar.gz' % td
- self._test_apply_sources(url, end_file)
+ dest = tempfile.mkdtemp()
+ self.addCleanup(os.rmdir, dest)
+ sources = {dest: url}
+ er = "mkdir -p '%s'; cd '%s'; curl -s '%s' | gunzip | tar -xvf -"
+ calls = popen_root_calls([er % (dest, dest, url)])
+ with mock.patch('subprocess.Popen') as mock_popen:
+ mock_popen.return_value = FakePOpen('Curl good')
+ sh = cfn_helper.SourcesHandler(sources)
+ sh.apply_sources()
+ mock_popen.assert_has_calls(calls)
def test_apply_source_cmd(self):
sh = cfn_helper.SourcesHandler({})
@@ -1293,4 +1305,4 @@ class TestSourcesHandler(testtools.TestCase):
url = 'http://www.example.com/a.sh'
cmd = sh._apply_source_cmd(dest, url)
self.assertEqual("", cmd)
- mock_mkdtemp.assert_run_with()
+ mock_mkdtemp.assert_called_with()