Prechádzať zdrojové kódy

Remove unnecessary docstrings from tests and replace with comments

Nuwan Goonasekera 7 rokov pred
rodič
commit
8b079da469

+ 3 - 18
test/test_block_store_service.py

@@ -21,10 +21,6 @@ class CloudBlockStoreServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['storage.volumes'])
     def test_crud_volume(self):
-        """
-        Create a new volume, check whether the expected values are set,
-        and delete it
-        """
         def create_vol(label):
             return self.provider.storage.volumes.create(
                 label, 1,
@@ -47,9 +43,6 @@ class CloudBlockStoreServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['storage.volumes'])
     def test_attach_detach_volume(self):
-        """
-        Create a new volume, and attempt to attach it to an instance
-        """
         label = "cb-attachvol-{0}".format(helpers.get_uuid())
         # Declare these variables and late binding will allow
         # the cleanup method access to the most current values
@@ -76,9 +69,6 @@ class CloudBlockStoreServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['storage.volumes'])
     def test_volume_properties(self):
-        """
-        Test volume properties
-        """
         label = "cb-volprops-{0}".format(helpers.get_uuid())
         vol_desc = 'newvoldesc1'
         # Declare these variables and late binding will allow
@@ -137,11 +127,9 @@ class CloudBlockStoreServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['storage.snapshots'])
     def test_crud_snapshot(self):
-        """
-        Create a new volume, create a snapshot of the volume, and check
-        whether list_snapshots properly detects the new snapshot.
-        Delete everything afterwards.
-        """
+        # Create a new volume, create a snapshot of the volume, and check
+        # whether list_snapshots properly detects the new snapshot.
+        # Delete everything afterwards.
         label = "cb-crudsnap-{0}".format(helpers.get_uuid())
         test_vol = self.provider.storage.volumes.create(
             label, 1,
@@ -181,9 +169,6 @@ class CloudBlockStoreServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['storage.snapshots'])
     def test_snapshot_properties(self):
-        """
-        Test snapshot properties
-        """
         label = "cb-snapprop-{0}".format(helpers.get_uuid())
         test_vol = self.provider.storage.volumes.create(
             label, 1,

+ 17 - 35
test/test_cloud_factory.py

@@ -16,28 +16,22 @@ class CloudFactoryTestCase(unittest.TestCase):
     _multiprocess_can_split_ = True
 
     def test_create_provider_valid(self):
-        """
-        Creating a provider with a known name should return
-        a valid implementation
-        """
+        # Creating a provider with a known name should return
+        # a valid implementation
         self.assertIsInstance(CloudProviderFactory().create_provider(
             factory.ProviderList.AWS, {}),
             interfaces.CloudProvider,
             "create_provider did not return a valid VM type")
 
     def test_create_provider_invalid(self):
-        """
-        Creating a provider with an invalid name should raise a
-        NotImplementedError
-        """
+        # Creating a provider with an invalid name should raise a
+        # NotImplementedError
         with self.assertRaises(NotImplementedError):
             CloudProviderFactory().create_provider("ec23", {})
 
     def test_find_provider_mock_valid(self):
-        """
-        Searching for a provider with a known mock driver should return
-        an implementation implementing helpers.TestMockHelperMixin
-        """
+        # Searching for a provider with a known mock driver should return
+        # an implementation implementing helpers.TestMockHelperMixin
         mock = CloudProviderFactory().get_provider_class(
             factory.ProviderList.AWS, get_mock=True)
         self.assertTrue(
@@ -55,24 +49,18 @@ class CloudFactoryTestCase(unittest.TestCase):
                 cls)
 
     def test_get_provider_class_valid(self):
-        """
-        Searching for a provider class with a known name should return a valid
-        class
-        """
+        # Searching for a provider class with a known name should return a
+        # valid class
         self.assertEqual(CloudProviderFactory().get_provider_class(
             factory.ProviderList.AWS), AWSCloudProvider)
 
     def test_get_provider_class_invalid(self):
-        """
-        Searching for a provider class with an invalid name should
-        return None
-        """
+        # Searching for a provider class with an invalid name should
+        # return None
         self.assertIsNone(CloudProviderFactory().get_provider_class("aws1"))
 
     def test_register_provider_class_invalid(self):
-        """
-        Attempting to register an invalid test class should be ignored
-        """
+        # Attempting to register an invalid test class should be ignored
         class DummyClass(object):
             PROVIDER_ID = 'aws'
 
@@ -82,10 +70,8 @@ class CloudFactoryTestCase(unittest.TestCase):
                         factory.get_all_provider_classes(get_mock=False))
 
     def test_register_provider_class_double(self):
-        """
-        Attempting to register the same class twice should register second
-        instance
-        """
+        # Attempting to register the same class twice should register second
+        # instance
         class DummyClass(CloudProvider):
             PROVIDER_ID = 'aws'
 
@@ -98,10 +84,8 @@ class CloudFactoryTestCase(unittest.TestCase):
                         factory.get_all_provider_classes(get_mock=False))
 
     def test_register_mock_provider_class_double(self):
-        """
-        Attempting to register the same mock provider twice should register
-        only the second instance
-        """
+        # Attempting to register the same mock provider twice should register
+        # only the second instance
         class DummyClass(CloudProvider, TestMockHelperMixin):
             PROVIDER_ID = 'aws'
 
@@ -114,10 +98,8 @@ class CloudFactoryTestCase(unittest.TestCase):
                         factory.get_all_provider_classes(get_mock=True))
 
     def test_register_provider_class_without_id(self):
-        """
-        Attempting to register a class without a PROVIDER_ID attribute
-        should be ignored.
-        """
+        # Attempting to register a class without a PROVIDER_ID attribute
+        # should be ignored.
         class DummyClass(CloudProvider):
             pass
 

+ 1 - 3
test/test_cloud_helpers.py

@@ -80,9 +80,7 @@ class CloudHelpersTestCase(ProviderTestBase):
             results.data
 
     def test_type_validation(self):
-        """
-        Make sure internal type checking implementation properly sets types.
-        """
+        # Make sure internal type checking implementation properly sets types.
         self.provider.config['text_type_check'] = 'test-text'
         config_value = self.provider._get_config_value('text_type_check', None)
         self.assertIsInstance(config_value, six.string_types)

+ 0 - 5
test/test_image_service.py

@@ -14,11 +14,6 @@ class CloudImageServiceTestCase(ProviderTestBase):
     @helpers.skipIfNoService(['compute.images', 'networking.networks',
                               'compute.instances'])
     def test_create_and_list_image(self):
-        """
-        Create a new image and check whether that image can be listed.
-        This covers waiting till the image is ready, checking that the image
-        label is the expected one and whether list_images is functional.
-        """
         instance_label = "cb-crudimage-{0}".format(helpers.get_uuid())
         img_inst_label = "cb-crudimage-{0}".format(helpers.get_uuid())
 

+ 5 - 13
test/test_interface.py

@@ -14,32 +14,24 @@ class CloudInterfaceTestCase(ProviderTestBase):
     _multiprocess_can_split_ = True
 
     def test_name_property(self):
-        """
-        Name should always return a value and should not raise an exception
-        """
+        # Name should always return a value and should not raise an exception
         assert self.provider.name
 
     def test_has_service_valid_service_type(self):
-        """
-        has_service with a valid service type should return
-        a boolean and raise no exceptions
-        """
+        # has_service with a valid service type should return
+        # a boolean and raise no exceptions
         for key, value in interfaces.CloudServiceType.__dict__.items():
             if not key.startswith("__"):
                 self.provider.has_service(value)
 
     def test_has_service_invalid_service_type(self):
-        """
-        has_service with an invalid service type should return False
-        """
+        # has_service with an invalid service type should return False
         self.assertFalse(
             self.provider.has_service("NON_EXISTENT_SERVICE"),
             "has_service should not return True for a non-existent service")
 
     def test_library_version(self):
-        """
-        Check that the library version can be retrieved.
-        """
+        # Check that the library version can be retrieved.
         self.assertIsNotNone(cloudbridge.get_version(),
                              "Did not get library version.")
 

+ 1 - 3
test/test_object_life_cycle.py

@@ -11,9 +11,7 @@ class CloudObjectLifeCycleTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['storage.volumes'])
     def test_object_life_cycle(self):
-        """
-        Test object life cycle methods by using a volume.
-        """
+        # Test object life cycle methods by using a volume.
         label = "cb-objlifecycle-{0}".format(helpers.get_uuid())
         test_vol = self.provider.storage.volumes.create(
             label, 1,

+ 6 - 14
test/test_object_store_service.py

@@ -23,10 +23,6 @@ class CloudObjectStoreServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['storage.buckets'])
     def test_crud_bucket(self):
-        """
-        Create a new bucket, check whether the expected values are set,
-        and delete it.
-        """
 
         def create_bucket(name):
             return self.provider.storage.buckets.create(name)
@@ -71,11 +67,9 @@ class CloudObjectStoreServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['storage.buckets'])
     def test_crud_bucket_object_properties(self):
-        """
-        Create a new bucket, upload some contents into the bucket, and
-        check whether list properly detects the new content.
-        Delete everything afterwards.
-        """
+        # Create a new bucket, upload some contents into the bucket, and
+        # check whether list properly detects the new content.
+        # Delete everything afterwards.
         name = "cbtestbucketobjs-{0}".format(helpers.get_uuid())
         test_bucket = self.provider.storage.buckets.create(name)
 
@@ -198,11 +192,9 @@ class CloudObjectStoreServiceTestCase(ProviderTestBase):
     @skip("Skip unless you want to test swift objects bigger than 5 Gig")
     @helpers.skipIfNoService(['storage.buckets'])
     def test_upload_download_bucket_content_with_large_file(self):
-        """
-        Creates a 6 Gig file in the temp directory, then uploads it to
-        Swift. Once uploaded, then downloads to a new file in the temp
-        directory and compares the two files to see if they match.
-        """
+        # Creates a 6 Gig file in the temp directory, then uploads it to
+        # Swift. Once uploaded, then downloads to a new file in the temp
+        # directory and compares the two files to see if they match.
         temp_dir = tempfile.gettempdir()
         file_name = '6GigTest.tmp'
         six_gig_file = os.path.join(temp_dir, file_name)

+ 0 - 13
test/test_region_service.py

@@ -13,10 +13,6 @@ class CloudRegionServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['compute.regions'])
     def test_get_and_list_regions(self):
-        """
-        Test whether the region listing methods work,
-        and whether zones are returned appropriately.
-        """
         regions = list(self.provider.compute.regions)
         sit.check_standard_behaviour(
             self, self.provider.compute.regions, regions[-1])
@@ -32,27 +28,18 @@ class CloudRegionServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['compute.regions'])
     def test_regions_unique(self):
-        """
-        Regions should not return duplicate items
-        """
         regions = self.provider.compute.regions.list()
         unique_regions = set([region.id for region in regions])
         self.assertTrue(len(regions) == len(list(unique_regions)))
 
     @helpers.skipIfNoService(['compute.regions'])
     def test_current_region(self):
-        """
-        RegionService.current should return a valid region
-        """
         current_region = self.provider.compute.regions.current
         self.assertIsInstance(current_region, Region)
         self.assertTrue(current_region in self.provider.compute.regions)
 
     @helpers.skipIfNoService(['compute.regions'])
     def test_zones(self):
-        """
-        Test whether regions return the correct zone information
-        """
         zone_find_count = 0
         test_zone = helpers.get_provider_test_data(self.provider, "placement")
         for region in self.provider.compute.regions:

+ 3 - 5
test/test_vm_types_service.py

@@ -63,11 +63,9 @@ class CloudVMTypeServiceTestCase(ProviderTestBase):
 
     @helpers.skipIfNoService(['compute.vm_types'])
     def test_vm_types_standard(self):
-        """
-        Searching for an instance by name should return an
-        VMType object and searching for a non-existent
-        object should return an empty iterator
-        """
+        # Searching for an instance by name should return an
+        # VMType object and searching for a non-existent
+        # object should return an empty iterator
         vm_type_name = helpers.get_provider_test_data(
             self.provider,
             "vm_type")