@@ -0,0 +1,3257 @@
+from unittest import TestCase%0Afrom fileflow.storage_drivers import get_storage_driver, FileStorageDriver, S3StorageDriver%0Afrom fileflow.errors import FileflowError%0Afrom moto import mock_s3%0Afrom nose.plugins.attrib import attr%0Aimport boto%0A%0A%0A@attr('unittest')%0A@mock_s3%0Aclass TestGetStorageDriver(TestCase):%0A    def setUp(self):%0A        %22%22%22%0A        Set up the moto connection.%0A        %22%22%22%0A        self.conn = boto.connect_s3()%0A%0A    def test_s3_production_environment(self):%0A        %22%22%22%0A        Test the storage driver and bucket name when using S3 in production.%0A        %22%22%22%0A        self.conn.create_bucket('the_bucket')%0A%0A        # s3, bucket_name, production, any, any%0A        driver = get_storage_driver(%0A            's3', '', 'production', '', '', 'the_bucket'%0A        )%0A        self.assertIsInstance(driver, S3StorageDriver)%0A        self.assertEqual(driver.bucket_name, 'the_bucket')%0A%0A    def test_s3_qa_environment(self):%0A        %22%22%22%0A        Test the storage driver and bucket name when using S3 in QA.%0A        %22%22%22%0A        self.conn.create_bucket('the_bucketqa')%0A%0A        # s3, bucket_name, qa, key1, key2%0A        driver = get_storage_driver('s3', '', 'qa', '', '', 'the_bucket')%0A        self.assertIsInstance(driver, S3StorageDriver)%0A        self.assertEqual(driver.bucket_name, 'the_bucketqa')%0A%0A    def test_s3_development_environment(self):%0A        %22%22%22%0A        Test the storage driver and bucket name when using S3 in development.%0A        %22%22%22%0A        self.conn.create_bucket('the_bucketdevelopment')%0A%0A        # s3, bucket_name, development, key1, key2%0A        driver = get_storage_driver(%0A            's3', '', 'development', '', '', 'the_bucket'%0A        )%0A        self.assertIsInstance(driver, S3StorageDriver)%0A        self.assertEqual(driver.bucket_name, 'the_bucketdevelopment')%0A%0A    def test_s3_test_environment(self):%0A        %22%22%22%0A        Test the storage driver and bucket name when using S3 in test.%0A        %22%22%22%0A        self.conn.create_bucket('the_buckettest')%0A%0A        # s3, bucket_name, test, key1, key2%0A        driver = get_storage_driver('s3', '', 'test', '', '', 'the_bucket')%0A        self.assertIsInstance(driver, S3StorageDriver)%0A        self.assertEqual(driver.bucket_name, 'the_buckettest')%0A%0A    def test_s3_bad_environment(self):%0A        %22%22%22%0A        Test an error is raised when using an incorrect environment name for%0A        S3 storage.%0A        %22%22%22%0A        # s3, bucket_name, bad_environment, key1, key2%0A        with self.assertRaises(FileflowError):%0A            get_storage_driver(%0A                's3', '', 'bad_environment', '', '', 'the_bucket'%0A            )%0A%0A    def test_file_driver(self):%0A        %22%22%22%0A        Test the file storage driver is returned when configured.%0A        %22%22%22%0A        # file, prefix, anything, anything, anything%0A        driver = get_storage_driver('file', '/the/prefix/', '', '', '')%0A        self.assertIsInstance(driver, FileStorageDriver)%0A        self.assertEqual(driver.prefix, '/the/prefix/')%0A%0A    def test_bad_storage_type(self):%0A        %22%22%22%0A        Test an error is raised when an unknown storage type is configured.%0A        %22%22%22%0A        # bad_storage_type, anything, anything, anything%0A        with self.assertRaises(FileflowError):%0A            get_storage_driver('bad_storage_type', '', '', '', '')%0A

add test for get_storage_driver