Ejemplo n.º 1
0
 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})
Ejemplo n.º 2
0
 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')
Ejemplo n.º 3
0
 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'
     )
Ejemplo n.º 4
0
 def _load_aliases(self):
     if os.path.exists(self._filename):
         return raw_config_parse(self._filename, parse_subsections=False)
     return {'toplevel': {}}
Ejemplo n.º 5
0
 def _load_aliases(self):
     if os.path.exists(self._filename):
         return raw_config_parse(
             self._filename, parse_subsections=False)
     return {'toplevel': {}}
Ejemplo n.º 6
0
 def test_config(self):
     loaded_config = raw_config_parse(path('aws_config'))
     self.assertIn('default', loaded_config)
     self.assertIn('profile "personal"', loaded_config)
Ejemplo n.º 7
0
 def test_config_parse_error(self):
     filename = path('aws_config_bad')
     with self.assertRaises(botocore.exceptions.ConfigParseError):
         raw_config_parse(filename)
Ejemplo n.º 8
0
 def test_config_not_found(self):
     with self.assertRaises(botocore.exceptions.ConfigNotFound):
         loaded_config = raw_config_parse(path('aws_config_notfound'))
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
 def test_config(self):
     loaded_config = raw_config_parse(path('aws_config'))
     self.assertIn('default', loaded_config)
     self.assertIn('profile "personal"', loaded_config)
Ejemplo n.º 11
0
 def test_config_parse_error(self):
     filename = path('aws_config_bad')
     with self.assertRaises(botocore.exceptions.ConfigParseError):
         raw_config_parse(filename)
Ejemplo n.º 12
0
 def test_config_not_found(self):
     with self.assertRaises(botocore.exceptions.ConfigNotFound):
         loaded_config = raw_config_parse(path('aws_config_notfound'))
Ejemplo n.º 13
0
 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})