2
0
Эх сурвалжийг харах

Improved test coverage. Removed redundant method rule_exists (same as
rule in sg.rules). Updated keystone version for py35 compatibility.

nuwan_ag 10 жил өмнө
parent
commit
257710f447

+ 2 - 2
.travis.yml

@@ -1,11 +1,11 @@
 language: python
-python: 3.4
+python: 3.5
 os:
   - linux
 #  - osx
 env:
   - TOX_ENV=py27
-  - TOX_ENV=py34
+  - TOX_ENV=py35
   - TOX_ENV=pypy
 matrix:
   fast_finish: true

+ 0 - 19
cloudbridge/cloud/base.py

@@ -480,25 +480,6 @@ class BaseSecurityGroup(SecurityGroup):
     def __ne__(self, other):
         return not self.__eq__(other)
 
-    def rule_exists(self, rules, rule):
-        """
-        Check if an authorization rule exists in a list of rules.
-
-        :type rules: list of :class:``.SecurityGroupRule``
-        :param rules: A list of rules to check against
-
-        :type rule: :class:``.SecurityGroupRule``
-        :param rule: A rule whose existence to check for
-
-        :rtype: bool
-        :return: ``True`` if an existing rule matches the supplied rule;
-                 ``False`` otherwise.
-        """
-        for r in rules:
-            if r == rule:
-                return True
-        return False
-
     @property
     def id(self):
         """

+ 0 - 26
cloudbridge/cloud/interfaces/resources.py

@@ -1161,32 +1161,6 @@ class SecurityGroup(object):
         """
         pass
 
-    @abstractmethod
-    def rule_exists(self, rules, from_port, to_port, ip_protocol, cidr_ip):
-        """
-        Check if an authorization rule with supplied parameters exists.
-
-        :type rules: list of :class:``.SecurityGroupRule`` SecurityGroupRule
-        :param rules: A list of rules to check against.
-
-        :type ip_protocol: str
-        :param ip_protocol: Either ``tcp`` | ``udp`` | ``icmp``.
-
-        :type from_port: int
-        :param from_port: The beginning port number.
-
-        :type to_port: int
-        :param to_port: The ending port number.
-
-        :type cidr_ip: str or list of strings
-        :param cidr_ip: The CIDR block.
-
-        :rtype: bool
-        :return: ``True`` if an existing rule matches supplied parameters;
-                 ``False`` otherwise.
-        """
-        pass
-
 
 class SecurityGroupRule(object):
 

+ 1 - 1
requirements.txt

@@ -1,3 +1,3 @@
 -e ".[full]"
-httpretty==0.8.5
 git+git://github.com/spulec/moto.git@ab3682a55c1c4f2983819e73a8cc59c0159a33f3
+git+git://github.com/openstack/python-keystoneclient.git@227e1b54cfc4a6a68268f9d5935d258b7490b7a3

+ 1 - 2
setup.py

@@ -1,8 +1,7 @@
 from setuptools import setup, find_packages
 
 base_reqs = ['bunch>=1.00', 'six>=1.9.0', 'retrying']
-openstack_reqs = ['python-keystoneclient',
-                  'python-novaclient', 'python-cinderclient',
+openstack_reqs = ['python-novaclient', 'python-cinderclient',
                   'python-swiftclient', 'python-neutronclient']
 aws_reqs = ['boto']
 full_reqs = base_reqs + aws_reqs + openstack_reqs

+ 22 - 0
test/test_instance_types_service.py

@@ -1,5 +1,9 @@
 import itertools
+from test import helpers
+
 import six
+
+from cloudbridge.cloud.interfaces.resources import InstanceType
 from test.helpers import ProviderTestBase
 
 
@@ -67,3 +71,21 @@ class CloudInstanceTypesServiceTestCase(ProviderTestBase):
                 inst_type.extra_data is None or isinstance(
                     inst_type.extra_data, dict),
                 "InstanceType extra_data must be None or a dict")
+
+    def test_instance_types_find(self):
+        """
+        Searching for an instance by name should return an
+        InstanceType object and searching for a non-existent
+        object should return an empty iterator
+        """
+        instance_type_name = helpers.get_provider_test_data(
+            self.provider,
+            "instance_type")
+        inst_type = next(self.provider.compute.instance_types.find(
+            name=instance_type_name))
+        self.assertTrue(isinstance(inst_type, InstanceType),
+                        "Find must return an InstanceType object")
+
+        with self.assertRaises(StopIteration):
+            inst_type = next(self.provider.compute.instance_types.find(
+                name="Non_Existent_Instance_Type"))

+ 11 - 0
test/test_object_store_service.py

@@ -20,6 +20,11 @@ class CloudObjectStoreServiceTestCase(ProviderTestBase):
         name = "cbtestcreatecontainer-{0}".format(uuid.uuid4())
         test_container = self.provider.object_store.create(name)
         with helpers.cleanup_action(lambda: test_container.delete()):
+            self.assertTrue(
+                test_container.id in repr(test_container),
+                "repr(obj) should contain the object id so that the object"
+                " can be reconstructed, but does not. eval(repr(obj)) == obj")
+
             containers = self.provider.object_store.list()
 
             # check iteration
@@ -43,6 +48,7 @@ class CloudObjectStoreServiceTestCase(ProviderTestBase):
                 " expected: {2}" .format(found_containers[0].id,
                                          get_container.id,
                                          test_container.name))
+
         containers = self.provider.object_store.list()
         found_containers = [c for c in containers if c.name == name]
         self.assertTrue(
@@ -67,6 +73,11 @@ class CloudObjectStoreServiceTestCase(ProviderTestBase):
             obj_name = "hello_world.txt"
             obj = test_container.create_object(obj_name)
 
+            self.assertTrue(
+                obj.id in repr(obj),
+                "repr(obj) should contain the object id so that the object"
+                " can be reconstructed, but does not. eval(repr(obj)) == obj")
+
             with helpers.cleanup_action(lambda: obj.delete()):
                 # TODO: This is wrong. We shouldn't have to have a separate
                 # call to upload some content before being able to delete

+ 1 - 1
tox.ini

@@ -4,7 +4,7 @@
 # and then run "tox" from this directory.
 
 [tox]
-envlist = py27, py34, pypy
+envlist = py27, py35, pypy
 
 [testenv]
 commands = {envpython} -m coverage run --branch --source=cloudbridge --omit=cloudbridge/cloud/interfaces/* setup.py test