]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Fix skips done in the test suite by using testtools skipIf
authorThomas Herve <therve@gmail.com>
Tue, 7 May 2013 16:59:46 +0000 (18:59 +0200)
committerThomas Herve <therve@gmail.com>
Tue, 7 May 2013 17:48:35 +0000 (19:48 +0200)
The shipped skip_if function was broken as skipIf is already a
decorator.

Change-Id: Ifc5c3a7878fa047fe1a807c43d91fe34bc7b4081

heat/tests/test_s3.py
heat/tests/test_swift.py
heat/tests/test_volume.py
heat/tests/utils.py

index 7bc6906a5f7bb3c23e6cc63b67477b70bbd80e38..e60874ca60649f54333864af38ddf0dd4cf89c98 100644 (file)
@@ -18,6 +18,8 @@ import re
 
 import mox
 
+from testtools import skipIf
+
 from heat.common import context
 from heat.common import template_format
 from heat.openstack.common.importutils import try_import
@@ -26,13 +28,12 @@ from heat.engine import parser
 from heat.engine import scheduler
 from heat.tests.common import HeatTestCase
 from heat.tests.utils import setup_dummy_db
-from heat.tests.utils import skip_if
 
 swiftclient = try_import('swiftclient.client')
 
 
 class s3Test(HeatTestCase):
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def setUp(self):
         super(s3Test, self).setUp()
         self.m.CreateMock(swiftclient.Connection)
@@ -69,7 +70,7 @@ class s3Test(HeatTestCase):
         self.assertEqual(s3.S3Bucket.CREATE_COMPLETE, resource.state)
         return resource
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_create_container_name(self):
         self.m.ReplayAll()
         t = self.load_template()
@@ -80,7 +81,7 @@ class s3Test(HeatTestCase):
         self.assertTrue(re.match(self.container_pattern,
                                  resource._create_container_name()))
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_attributes(self):
         swiftclient.Connection.put_container(
             mox.Regex(self.container_pattern),
@@ -118,7 +119,7 @@ class s3Test(HeatTestCase):
         resource.delete()
         self.m.VerifyAll()
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_public_read(self):
         swiftclient.Connection.put_container(
             mox.Regex(self.container_pattern),
@@ -136,7 +137,7 @@ class s3Test(HeatTestCase):
         resource.delete()
         self.m.VerifyAll()
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_public_read_write(self):
         swiftclient.Connection.put_container(
             mox.Regex(self.container_pattern),
@@ -154,7 +155,7 @@ class s3Test(HeatTestCase):
         resource.delete()
         self.m.VerifyAll()
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_authenticated_read(self):
         swiftclient.Connection.put_container(
             mox.Regex(self.container_pattern),
@@ -172,7 +173,7 @@ class s3Test(HeatTestCase):
         resource.delete()
         self.m.VerifyAll()
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_website(self):
 
         swiftclient.Connection.put_container(
@@ -191,7 +192,7 @@ class s3Test(HeatTestCase):
         resource.delete()
         self.m.VerifyAll()
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_delete_exception(self):
 
         swiftclient.Connection.put_container(
@@ -210,7 +211,7 @@ class s3Test(HeatTestCase):
 
         self.m.VerifyAll()
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_delete_retain(self):
 
         # first run, with retain policy
index da9a2d16935a78fd92f7674761e5e524086ab59f..aa34bcc636327e5bfb3b43883b73a635fa40f6ae 100644 (file)
@@ -18,6 +18,8 @@ import re
 
 import mox
 
+from testtools import skipIf
+
 from heat.common import context
 from heat.common import template_format
 from heat.openstack.common.importutils import try_import
@@ -26,13 +28,12 @@ from heat.engine import parser
 from heat.engine import scheduler
 from heat.tests.common import HeatTestCase
 from heat.tests.utils import setup_dummy_db
-from heat.tests.utils import skip_if
 
 swiftclient = try_import('swiftclient.client')
 
 
 class swiftTest(HeatTestCase):
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def setUp(self):
         super(swiftTest, self).setUp()
         self.m.CreateMock(swiftclient.Connection)
@@ -71,7 +72,7 @@ class swiftTest(HeatTestCase):
         self.assertEqual(swift.SwiftContainer.CREATE_COMPLETE, resource.state)
         return resource
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_create_container_name(self):
         self.m.ReplayAll()
         t = self.load_template()
@@ -87,7 +88,7 @@ class swiftTest(HeatTestCase):
             'the_name',
             resource._create_container_name('the_name'))
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_build_meta_headers(self):
         self.m.UnsetStubs()
         self.assertEqual({}, swift.SwiftContainer._build_meta_headers({}))
@@ -101,7 +102,7 @@ class swiftTest(HeatTestCase):
             "Web-Error": "error.html"
         }))
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_attributes(self):
         headers = {
             "content-length": "0",
@@ -156,7 +157,7 @@ class swiftTest(HeatTestCase):
         resource.delete()
         self.m.VerifyAll()
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_public_read(self):
         swiftclient.Connection.put_container(
             mox.Regex(self.container_pattern),
@@ -174,7 +175,7 @@ class swiftTest(HeatTestCase):
         resource.delete()
         self.m.VerifyAll()
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_public_read_write(self):
         swiftclient.Connection.put_container(
             mox.Regex(self.container_pattern),
@@ -193,7 +194,7 @@ class swiftTest(HeatTestCase):
         resource.delete()
         self.m.VerifyAll()
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_website(self):
 
         swiftclient.Connection.put_container(
@@ -212,7 +213,7 @@ class swiftTest(HeatTestCase):
         resource.delete()
         self.m.VerifyAll()
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_delete_exception(self):
 
         swiftclient.Connection.put_container(
@@ -231,7 +232,7 @@ class swiftTest(HeatTestCase):
 
         self.m.VerifyAll()
 
-    @skip_if(swiftclient is None, 'unable to import swiftclient')
+    @skipIf(swiftclient is None, 'unable to import swiftclient')
     def test_delete_retain(self):
 
         # first run, with retain policy
index 4041f1aa65622a246826211e25a29c9225cca6cf..624cb20c7443a7f102822bbc7400401e1f460ea3 100644 (file)
@@ -17,6 +17,8 @@ import os
 
 import eventlet
 
+from testtools import skipIf
+
 from heat.common import context
 from heat.common import exception
 from heat.common import template_format
@@ -27,7 +29,7 @@ from heat.engine import clients
 from heat.openstack.common.importutils import try_import
 from heat.tests.common import HeatTestCase
 from heat.tests.v1_1 import fakes
-from heat.tests.utils import setup_dummy_db, skip_if
+from heat.tests.utils import setup_dummy_db
 
 from cinderclient.v1 import client as cinderclient
 
@@ -236,7 +238,7 @@ class VolumeTest(HeatTestCase):
 
         self.m.VerifyAll()
 
-    @skip_if(volume_backups is None, 'unable to import volume_backups')
+    @skipIf(volume_backups is None, 'unable to import volume_backups')
     def test_snapshot(self):
         stack_name = 'test_volume_stack'
         fv = FakeVolume('creating', 'available')
@@ -268,7 +270,7 @@ class VolumeTest(HeatTestCase):
 
         self.m.VerifyAll()
 
-    @skip_if(volume_backups is None, 'unable to import volume_backups')
+    @skipIf(volume_backups is None, 'unable to import volume_backups')
     def test_snapshot_error(self):
         stack_name = 'test_volume_stack'
         fv = FakeVolume('creating', 'available')
@@ -298,6 +300,7 @@ class VolumeTest(HeatTestCase):
 
         self.m.VerifyAll()
 
+    @skipIf(volume_backups is None, 'unable to import volume_backups')
     def test_snapshot_no_volume(self):
         stack_name = 'test_volume_stack'
         fv = FakeVolume('creating', 'error')
index 4f2900ed97f24982a2ea9f39a39243dcc7d8e071..0e46ce0be54956d3858b3d15c2d8d96fa6e87178 100644 (file)
@@ -15,8 +15,6 @@
 import sys
 import functools
 
-from testtools import skipIf
-
 from heat.common import context
 from heat.engine import parser
 
@@ -24,22 +22,6 @@ from heat.db.sqlalchemy.session import get_engine
 from heat.db import migration
 
 
-class skip_if(object):
-    """Decorator that skips a test if condition is true."""
-    def __init__(self, condition, msg):
-        self.condition = condition
-        self.message = msg
-
-    def __call__(self, func):
-        def _skipper(*args, **kw):
-            """Wrapped skipper function."""
-            skipIf(self.condition, self.message)
-            func(*args, **kw)
-        _skipper.__name__ = func.__name__
-        _skipper.__doc__ = func.__doc__
-        return _skipper
-
-
 def stack_delete_after(test_fn):
     """
     Decorator which calls test class self.stack.delete()