Пример #1
0
    def test_make_crud_args_without_default_values(self):
        cli_arguments = "s3_wrapper.py download -aki aaa -sak bbb -lf ccc -k ddd -bn mybucket".split()
        # Execute
        parsed_args = s3_wrapper.parse_cli_arguments(cli_arguments[1:])

        actual = s3_wrapper.make_crud_args(parsed_args)
        expected = {'aws_access_key_id': 'aaa',
                    'bucket_name': 'mybucket',
                    'aws_secret_access_key': 'bbb'}

        self.assertEqual(expected, actual)
Пример #2
0
    def test_make_crud_args_without_default_values(self):
        cli_arguments = "s3_wrapper.py download -aki aaa -sak bbb -lf ccc -k ddd -bn mybucket".split(
        )
        # Execute
        parsed_args = s3_wrapper.parse_cli_arguments(cli_arguments[1:])

        actual = s3_wrapper.make_crud_args(parsed_args)
        expected = {
            'aws_access_key_id': 'aaa',
            'bucket_name': 'mybucket',
            'aws_secret_access_key': 'bbb'
        }

        self.assertEqual(expected, actual)
Пример #3
0
    def test_make_crud_args_use_default_values(self):
        cli_arguments = ("s3_wrapper.py download -aki aaa -sak bbb -lf ccc -k ddd --access-preset " +
                         s3_wrapper._DIGITALOCEAN_PRIVATE).split()
        # Execute
        parsed_args = s3_wrapper.parse_cli_arguments(cli_arguments[1:])
        defr = MappingProxyType({s3_wrapper._DIGITALOCEAN_PRIVATE: {'bucket_name': '_DIGITALOCEAN_bucket_name',
                                                            'endpoint_url': '_DIGITALOCEAN_endpoint_url'}})

        actual = s3_wrapper.make_crud_args(parsed_args, defr)
        expected = {'aws_access_key_id': 'aaa',
                    'bucket_name': '_DIGITALOCEAN_bucket_name',
                    'endpoint_url': '_DIGITALOCEAN_endpoint_url',
                    'aws_secret_access_key': 'bbb'}

        self.assertEqual(expected, actual)
Пример #4
0
 def test_cli_with_list_command(self):
     # Prepare
     arguments = "s3_wrapper.py list -aki aaa -sak bbb -pf pre -rf reg".split(
     )
     # Execute
     actual = s3_wrapper.parse_cli_arguments(arguments[1:]).__dict__
     # Expected
     expected = dict(access_key_id='aaa',
                     command='list',
                     secret_access_key='bbb',
                     bucket_name='obus-do1',
                     prefix_filter='pre',
                     regex_filter='reg')
     # Test
     self.assertEqual(expected, actual)
Пример #5
0
 def test_cli_with_download_command_with_default_bucket_name(self):
     # Prepare
     arguments = "s3_wrapper.py download -aki aaa -sak bbb -lf ccc -k ddd".split(
     )
     # Execute
     actual = s3_wrapper.parse_cli_arguments(arguments[1:]).__dict__
     # Expected
     expected = dict(access_key_id='aaa',
                     command='download',
                     cloud_key='ddd',
                     local_file='ccc',
                     secret_access_key='bbb',
                     bucket_name='obus-do1')
     # Test
     self.assertEqual(actual, expected)
Пример #6
0
 def test_cli_with_download_command_with_default_bucket_name(self):
     # Prepare
     arguments = "s3_wrapper.py download -aki aaa -sak bbb -lf ccc -k ddd".split()
     # Execute
     actual = s3_wrapper.parse_cli_arguments(arguments[1:]).__dict__
     # Expected
     expected = dict(aws_access_key_id='aaa',
                     command='download',
                     cloud_key='ddd',
                     local_file='ccc',
                     aws_secret_access_key='bbb',
                     bucket_name=None,
                     endpoint_url=None,
                     access_preset=None)
     # Test
     self.assertEqual(expected, actual)
Пример #7
0
 def test_cli_with_list_command(self):
     # Prepare
     arguments = "s3_wrapper.py list -aki aaa -sak bbb -pf pre -rf reg".split()
     # Execute
     actual = s3_wrapper.parse_cli_arguments(arguments[1:]).__dict__
     # Expected
     expected = dict(aws_access_key_id='aaa',
                     command='list',
                     aws_secret_access_key='bbb',
                     bucket_name=None,
                     prefix_filter='pre',
                     regex_filter='reg',
                     endpoint_url=None,
                     access_preset=None)
     # Test
     self.assertEqual(expected, actual)
Пример #8
0
 def test_cli_with_upload_command(self):
     # Prepare
     arguments = "s3_wrapper.py upload -aki aaa -sak bbb -lf ccc -k ddd -bn bucket42".split(
     )
     # Execute
     actual = s3_wrapper.parse_cli_arguments(arguments[1:]).__dict__
     # Expected
     expected = dict(access_key_id='aaa',
                     command='upload',
                     cloud_key='ddd',
                     local_file='ccc',
                     secret_access_key='bbb',
                     bucket_name='bucket42',
                     is_folder=False)
     # Test
     self.assertEqual(actual, expected)
Пример #9
0
 def test_cli_with_download_command(self):
     # Prepare
     arguments = "s3_wrapper.py download -aki aaa -sak bbb -lf ccc -k ddd -bn bucket42".split(
     )
     # Execute
     actual = s3_wrapper.parse_cli_arguments(arguments[1:]).__dict__
     # Expected
     expected = dict(aws_access_key_id='aaa',
                     command='download',
                     cloud_key='ddd',
                     local_file='ccc',
                     aws_secret_access_key='bbb',
                     bucket_name='bucket42',
                     endpoint_url=None,
                     access_preset=None)
     # Test
     self.assertEqual(expected, actual)
Пример #10
0
 def test_cli_with_upload_command(self):
     # Prepare
     arguments = "s3_wrapper.py upload -aki aaa -sak bbb -lf ccc -k ddd -bn bucket42".split()
     # Execute
     actual = s3_wrapper.parse_cli_arguments(arguments[1:]).__dict__
     # Expected
     expected = dict(aws_access_key_id='aaa',
                     command='upload',
                     cloud_key='ddd',
                     local_file='ccc',
                     aws_secret_access_key='bbb',
                     bucket_name='bucket42',
                     is_folder=False,
                     path_filter=None,
                     endpoint_url=None,
                     access_preset= None)
     # Test
     self.assertEqual(expected, actual)
Пример #11
0
 def test_cli_with_upload_command_with_default_bucket_name(self):
     # Prepare
     arguments = "s3_wrapper.py upload -aki aaa -sak bbb -lf ccc -k ddd".split(
     )
     # Execute
     actual = s3_wrapper.parse_cli_arguments(arguments[1:]).__dict__
     # Expected
     expected = dict(aws_access_key_id='aaa',
                     command='upload',
                     cloud_key='ddd',
                     local_file='ccc',
                     aws_secret_access_key='bbb',
                     bucket_name=None,
                     is_folder=False,
                     path_filter=None,
                     endpoint_url=None,
                     access_preset=None)
     # Test
     self.assertEqual(expected, actual)
Пример #12
0
    def test_make_crud_args_use_default_values(self):
        cli_arguments = (
            "s3_wrapper.py download -aki aaa -sak bbb -lf ccc -k ddd --access-preset "
            + s3_wrapper._DIGITALOCEAN_PRIVATE).split()
        # Execute
        parsed_args = s3_wrapper.parse_cli_arguments(cli_arguments[1:])
        defr = MappingProxyType({
            s3_wrapper._DIGITALOCEAN_PRIVATE: {
                'bucket_name': '_DIGITALOCEAN_bucket_name',
                'endpoint_url': '_DIGITALOCEAN_endpoint_url'
            }
        })

        actual = s3_wrapper.make_crud_args(parsed_args, defr)
        expected = {
            'aws_access_key_id': 'aaa',
            'bucket_name': '_DIGITALOCEAN_bucket_name',
            'endpoint_url': '_DIGITALOCEAN_endpoint_url',
            'aws_secret_access_key': 'bbb'
        }

        self.assertEqual(expected, actual)