예제 #1
0
    def test_boto3_not_installed(self):
        from central.config import s3
        boto3_tmp = s3.boto3
        s3.boto3 = None

        with self.assertRaises(LibraryRequiredError):
            S3Config(self.s3, 'bucket name', 'config.json')

        s3.boto3 = boto3_tmp
예제 #2
0
 def test_init_reader_with_reader_value(self):
     reader = JsonReader()
     config = S3Config(client=self.s3, bucket_name='bucket name', filename='config.json', reader=reader)
     self.assertEqual(reader, config.reader)
예제 #3
0
 def test_init_reader_with_str_value(self):
     with self.assertRaises(TypeError):
         S3Config(client=self.s3, bucket_name='bucket name', filename='config.json', reader='non raeader')
예제 #4
0
 def test_get_reader_with_default_value(self):
     config = S3Config(client=self.s3, bucket_name='bucket name', filename='config.json')
     self.assertIsNone(config.reader)
예제 #5
0
 def test_init_filename_with_str_value(self):
     config = S3Config(client=self.s3, bucket_name='bucket name', filename='config.json')
     self.assertEqual('config.json', config.filename)
예제 #6
0
 def test_init_filename_with_int_value(self):
     with self.assertRaises(TypeError):
         S3Config(client=self.s3, bucket_name='bucket name', filename=123)
예제 #7
0
 def test_init_bucket_name_with_none_value(self):
     with self.assertRaises(TypeError):
         S3Config(client=self.s3, bucket_name=None, filename='config.json')
예제 #8
0
 def test_load_without_file_extension(self):
     config = S3Config(client=self.s3, bucket_name='bucket name', filename='./config')
     with self.assertRaises(ConfigError):
         config.load()
예제 #9
0
#
# UPLOAD config.json into your S3 Account
#

import boto3

from central.config.s3 import S3Config

s3 = boto3.resource('s3')

config = S3Config(s3, 'bucket-name', 'config.json')
config.load()

print(config.get('timeout'))
print(config.get('database'))
print(config.get('database.host'))
print(config.get('database.port'))