def test_validate_configuration_missing(self): """Tests validating a configuration with missing attributes""" json_config = { 'type': S3Broker().broker_type, } broker = S3Broker() self.assertRaises(InvalidBrokerConfiguration, broker.validate_configuration, json_config)
def test_validate_configuration_roles(self): """Tests validating a configuration based on IAM roles successfully""" json_config = { 'type': S3Broker().broker_type, 'bucket_name': 'my_bucket.domain.com', } broker = S3Broker() # No exception is success broker.load_configuration(json_config)
def setUp(self): django.setup() self.broker = S3Broker() self.broker.load_configuration({ 'type': S3Broker().broker_type, 'bucket_name': 'my_bucket.domain.com', 'credentials': { 'access_key_id': 'ABC', 'secret_access_key': '123', }, })
def test_validate_configuration_keys(self): """Tests validating a configuration based on IAM keys successfully""" json_config = { 'type': S3Broker().broker_type, 'bucket_name': 'my_bucket.domain.com', 'credentials': { 'access_key_id': 'ABC', 'secret_access_key': '123', }, } broker = S3Broker() # No exception is success broker.load_configuration(json_config)
def test_load_configuration(self): """Tests loading a valid configuration successfully""" json_config = { 'type': S3Broker().broker_type, 'bucket_name': 'my_bucket.domain.com', 'credentials': { 'access_key_id': 'ABC', 'secret_access_key': '123', }, } broker = S3Broker() broker.load_configuration(json_config) self.assertEqual(broker._bucket_name, 'my_bucket.domain.com') self.assertEqual(broker._credentials.access_key_id, 'ABC') self.assertEqual(broker._credentials.secret_access_key, '123')
def test_load_configuration_whitespace_filled_host_path(self): """Tests loading a valid configuration successfully while purging empty host_path value""" json_config = { 'type': S3Broker().broker_type, 'bucket_name': 'my_bucket.domain.com', 'host_path': ' ', 'credentials': { 'access_key_id': 'ABC', 'secret_access_key': '123', }, } broker = S3Broker() broker.load_configuration(json_config) self.assertEqual(broker._bucket_name, 'my_bucket.domain.com') self.assertIsNone(broker._volume) self.assertEqual(broker._credentials.access_key_id, 'ABC') self.assertEqual(broker._credentials.secret_access_key, '123')