]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Fixed the interpretation of the file extension.
authorAngus Salkeld <asalkeld@redhat.com>
Thu, 3 May 2012 13:26:25 +0000 (23:26 +1000)
committerAngus Salkeld <asalkeld@redhat.com>
Thu, 3 May 2012 13:26:47 +0000 (23:26 +1000)
My initial lack of understanding of "is" and "==".

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
heat/cfntools/cfn_helper.py
heat/tests/test_cfn.py

index fa0812ea1554722328c1120a4bbdaf646df4b94d..5322cb3630a79787bab618224c61423a3f3d6a0c 100644 (file)
@@ -575,13 +575,13 @@ class SourcesHandler(object):
     def _decompress(self, archive, dest_dir):
         cmd_str = ''
         (r, ext) = os.path.splitext(archive)
-        if ext is 'tar.gz' or ext is 'tgz':
+        if ext == '.tar.gz' or ext == '.tgz':
             cmd_str = 'tar -C %s -xzf %s' % (dest_dir, archive)
-        elif ext is 'tar.bz2' or ext is 'tbz2':
+        elif ext == '.tar.bz2' or ext == '.tbz2':
             cmd_str = 'tar -C %s -xjf %s' % (dest_dir, archive)
-        elif ext is 'zip':
+        elif ext == '.zip':
             cmd_str = 'unzip -d %s %s' % (dest_dir, archive)
-        elif ext is 'tar':
+        elif ext == '.tar':
             cmd_str = 'tar -C %s -xf %s' % (dest_dir, archive)
         else:
             pass
index 5a2f1e30c557ad582f9d15bb6620f63fa87b9a40..6d68774a1113b033b3916786ec254246f88fe043 100644 (file)
@@ -140,6 +140,9 @@ class MetadataTest(unittest.TestCase):
         j = ''' {
         "AWS::CloudFormation::Init" : {
           "config" : {
+            "sources": {
+              "/home/ec2-user/sample" : "https://s3.amazonaws.com/cloudformation-examples/CloudFormationRailsSample.zip"
+             },
             "files" : {
               "/tmp/_files_test_/epel.repo" : {
           "source" : "https://raw.github.com/heat-api/heat/master/README.rst",
@@ -175,6 +178,17 @@ class MetadataTest(unittest.TestCase):
         self.m.StubOutWithMock(os, 'chown')
         self.m.StubOutWithMock(os, 'chmod')
 
+        subprocess.Popen(['su', 'root', '-c',
+                          'wget -O /tmp/CloudFormationRailsSample.zip \
+https://s3.amazonaws.com/cloudformation-examples/CloudFormationRailsSample.zip'],
+                          stdout=subprocess.PIPE,
+                          stderr=subprocess.PIPE).AndReturn(PopenMock())
+
+        subprocess.Popen(['su', 'root', '-c',
+'unzip -d /home/ec2-user/sample /tmp/CloudFormationRailsSample.zip'],
+                          stdout=subprocess.PIPE,
+                          stderr=subprocess.PIPE).AndReturn(PopenMock())
+
         subprocess.Popen(['su', 'root', '-c',
                           'wget -O /tmp/_files_test_/epel.repo \
 https://raw.github.com/heat-api/heat/master/README.rst'],