Esempio n. 1
0
    def get_resource_class(self):
        if self._resource_class is None:
            raise ResourceError(
                "No resource_class configured for '{0}.".format(
                    self.__class__.__name__
                )
            )

        if isinstance(self._resource_class, six.string_types):
            # We've got a path. Try to import it.
            self._resource_class = import_class(self._resource_class)

        return self._resource_class
Esempio n. 2
0
    def test_import_class_empty_string(self):
        with self.assertRaises(IncorrectImportPath) as cm:
            klass = import_class('')

        self.assertTrue('Invalid Python' in str(cm.exception))
Esempio n. 3
0
 def test_import_class(self):
     klass = import_class('boto3.core.session.Session')
     self.assertEqual(klass, Session)
Esempio n. 4
0
    def test_import_class_invalid_class(self):
        with self.assertRaises(IncorrectImportPath) as cm:
            klass = import_class('boto3.core.session.NopeSession')

        self.assertTrue('could not find' in str(cm.exception))
Esempio n. 5
0
    def test_import_class_invalid_path(self):
        with self.assertRaises(IncorrectImportPath) as cm:
            klass = import_class('boto3.nosuchmodule.Nope')

        self.assertTrue('Could not import' in str(cm.exception))