Beispiel #1
0
 def setUp(self):
     self.resfactory = ResourcesFactory()
     self.resfactory.clear()
Beispiel #2
0
 def setUp(self):
     self.resfactory = ResourcesFactory()
     self.resfactory.clear()
Beispiel #3
0
class ResourceFactoryTestCase(unittest.TestCase):
    def setUp(self):
        self.resfactory = ResourcesFactory()
        self.resfactory.clear()

    def _load(self, resources):
        """ Helper for load the resources
        :param resources: list of tuples (map, priority)
        """
        for obj, priority in resources:
            self.resfactory.loadResource(obj, priority)

    def getValue(self, resources, key, expected_value):
        """ Helper for test the resourcefactory getValue method
        :param resources: list of tuple (map, priority)
        :param key: name of the key
        :param expected_value: Is the expected URI
        """
        self._load(resources)
        value = self.resfactory.getValue(key)
        msg = 'The expected value is %s, got %s' % (expected_value, value)
        self.assertEqual(value, expected_value, msg)

    def getAttribute(self, resources, uri, expected_attr_uri):
        """ Helper for test the getAttribute method
        :param resources: list of tuple (map, priority)
        :param uri: res scheme uri.
        :param expected_attr_uri: a scheme uri
        """
        self._load(resources)
        expected_attr = taurus.Attribute(expected_attr_uri)
        res_attr = self.resfactory.getAttribute(uri)
        msg = 'Attributes are different, expected %s, got %s' % (expected_attr,
                                                                 res_attr)
        self.assertIs(expected_attr, res_attr, msg)

    def getDevice(self, resources, uri, expected_attr_uri):
        """ Helper for test the getDevice method
        :param resources: list of tuple (map, priority)
        :param uri: res scheme uri.
        :param expected_attr_uri: a scheme uri
        """
        self._load(resources)
        expected_dev = taurus.Device(expected_attr_uri)
        res_dev = self.resfactory.getDevice(uri)
        msg = 'Devices are different, expected %s, got %s' % (expected_dev,
                                                              res_dev)
        self.assertIs(expected_dev, res_dev, msg)

    def getAuthority(self, resources, uri, expected_attr_uri):
        """ Helper for test the getAuthority method
        :param resources: list of tuple (map, priority)
        :param uri: res scheme uri.
        :param expected_attr_uri: a scheme uri
        """
        self._load(resources)
        expected_auth = taurus.Authority(expected_attr_uri)
        res_auth = self.resfactory.getAuthority(uri)
        msg = 'Authorities are different, expected %s, got %s' % (
            expected_auth, res_auth)
        self.assertIs(expected_auth, res_auth, msg)

    def tearDown(self):
        self.resfactory.clear()
Beispiel #4
0
class ResourceFactoryTestCase(unittest.TestCase):

    def setUp(self):
        self.resfactory = ResourcesFactory()
        self.resfactory.clear()

    def _load(self, resources):
        """ Helper for load the resources
        :param resources: list of tuples (map, priority)
        """
        for obj, priority in resources:
            self.resfactory.loadResource(obj, priority)

    def getValue(self, resources, key, expected_value):
        """ Helper for test the resourcefactory getValue method
        :param resources: list of tuple (map, priority)
        :param key: name of the key
        :param expected_value: Is the expected URI
        """
        self._load(resources)
        value = self.resfactory.getValue(key)
        msg = 'The expected value is %s, got %s' % (expected_value, value)
        self.assertEqual(value, expected_value, msg)

    def getAttribute(self, resources, uri, expected_attr_uri):
        """ Helper for test the getAttribute method
        :param resources: list of tuple (map, priority)
        :param uri: res scheme uri.
        :param expected_attr_uri: a scheme uri
        """
        self._load(resources)
        expected_attr = taurus.Attribute(expected_attr_uri)
        res_attr = self.resfactory.getAttribute(uri)
        msg = 'Attributes are different, expected %s, got %s' % (expected_attr,
                                                                 res_attr)
        self.assertIs(expected_attr, res_attr, msg)

    def getDevice(self, resources, uri, expected_attr_uri):
        """ Helper for test the getDevice method
        :param resources: list of tuple (map, priority)
        :param uri: res scheme uri.
        :param expected_attr_uri: a scheme uri
        """
        self._load(resources)
        expected_dev = taurus.Device(expected_attr_uri)
        res_dev = self.resfactory.getDevice(uri)
        msg = 'Devices are different, expected %s, got %s' % (expected_dev,
                                                              res_dev)
        self.assertIs(expected_dev, res_dev, msg)

    def getAuthority(self, resources, uri, expected_attr_uri):
        """ Helper for test the getAuthority method
        :param resources: list of tuple (map, priority)
        :param uri: res scheme uri.
        :param expected_attr_uri: a scheme uri
        """
        self._load(resources)
        expected_auth = taurus.Authority(expected_attr_uri)
        res_auth = self.resfactory.getAuthority(uri)
        msg = 'Authorities are different, expected %s, got %s' % (expected_auth,
                                                                  res_auth)
        self.assertIs(expected_auth, res_auth, msg)

    def tearDown(self):
        self.resfactory.clear()