def __init__(self, client, args, config_file_path="~/.spotr/config"): self.client = client config_file_path = os.path.expanduser(config_file_path) if os.path.isfile(config_file_path): self._config = raw_config_parse(config_file_path)['config'] else: self._config = {} self._config.update({k: v for k, v in six.iteritems(vars(args)) if v})
def test_nested_hierarchy_with_no_subsection_parsing(self): filename = path('aws_config_nested') raw_config = raw_config_parse(filename, False)['default'] self.assertEqual(raw_config['aws_access_key_id'], 'foo') self.assertEqual(raw_config['region'], 'us-west-2') # Specifying False for pase_subsections in raw_config_parse # will make sure that indented sections such as singature_version # will not be treated as another subsection but rather # its literal value. self.assertEqual(raw_config['cloudwatch'], '\nsignature_version = v4') self.assertEqual( raw_config['s3'], '\nsignature_version = s3v4' '\naddressing_style = path')
def test_nested_hierarchy_with_no_subsection_parsing(self): filename = path('aws_config_nested') raw_config = raw_config_parse(filename, False)['default'] self.assertEqual(raw_config['aws_access_key_id'], 'foo') self.assertEqual(raw_config['region'], 'us-west-2') # Specifying False for pase_subsections in raw_config_parse # will make sure that indented sections such as singature_version # will not be treated as another subsection but rather # its literal value. self.assertEqual( raw_config['cloudwatch'], '\nsignature_version = v4') self.assertEqual( raw_config['s3'], '\nsignature_version = s3v4' '\naddressing_style = path' )
def _load_aliases(self): if os.path.exists(self._filename): return raw_config_parse(self._filename, parse_subsections=False) return {'toplevel': {}}
def _load_aliases(self): if os.path.exists(self._filename): return raw_config_parse( self._filename, parse_subsections=False) return {'toplevel': {}}
def test_config(self): loaded_config = raw_config_parse(path('aws_config')) self.assertIn('default', loaded_config) self.assertIn('profile "personal"', loaded_config)
def test_config_parse_error(self): filename = path('aws_config_bad') with self.assertRaises(botocore.exceptions.ConfigParseError): raw_config_parse(filename)
def test_config_not_found(self): with self.assertRaises(botocore.exceptions.ConfigNotFound): loaded_config = raw_config_parse(path('aws_config_notfound'))
def test_config_parse_error_filesystem_encoding_none(self): filename = path('aws_config_bad') with mock.patch('sys.getfilesystemencoding') as encoding: encoding.return_value = None with self.assertRaises(botocore.exceptions.ConfigParseError): raw_config_parse(filename)
def __init__(self, client, args): self.client = client self._config = raw_config_parse("~/.spotr/config")['config'] self._config.update({k: v for k, v in vars(args).iteritems() if v})