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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)