def test_from_config_verify(self): self._prepare_test_config() sot = connection.from_config(cloud_name="insecure") self.assertFalse(sot.session.verify) sot = connection.from_config(cloud_name="cacert") self.assertEqual(CONFIG_CACERT, sot.session.verify)
def test_from_config_given_name(self): self._prepare_test_config() sot = connection.from_config(cloud_name="sample") self.assertEqual(CONFIG_USERNAME, sot.authenticator._username) self.assertEqual(CONFIG_PASSWORD, sot.authenticator._password) self.assertEqual(CONFIG_AUTH_URL, sot.authenticator.auth_url) self.assertEqual(CONFIG_PROJECT, sot.authenticator._project_name)
def test_from_config_given_data(self): self._prepare_test_config() data = os_client_config.OpenStackConfig().get_one_cloud("sample") sot = connection.from_config(cloud_config=data) self.assertEqual(CONFIG_USERNAME, sot.authenticator._username) self.assertEqual(CONFIG_PASSWORD, sot.authenticator._password) self.assertEqual(CONFIG_AUTH_URL, sot.authenticator.auth_url) self.assertEqual(CONFIG_PROJECT, sot.authenticator._project_name)
def test_from_config_given_options(self): self._prepare_test_config() version = "100" class Opts(object): compute_api_version = version sot = connection.from_config(cloud_name="sample", options=Opts) pref = sot.session.profile.get_filter("compute") # NOTE: Along the way, the `v` prefix gets added so we can build # up URLs with it. self.assertEqual("v" + version, pref.version)
def service_exists(**kwargs): """Decorator function to check whether a service exists Usage: @unittest.skipUnless(base.service_exists(service_type="metering"), "Metering service does not exist") class TestMeter(base.BaseFunctionalTest): ... :param kwargs: The kwargs needed to filter an endpoint. :returns: True if the service exists, otherwise False. """ try: conn = connection.from_config(cloud_name=TEST_CLOUD) conn.session.get_endpoint(**kwargs) return True except _exceptions.EndpointNotFound: return False
def setUpClass(cls): cls.conn = connection.from_config(cloud_name=TEST_CLOUD)