Beispiel #1
0
 def test_verify_actions(self):
     c = config.BaseConfig(initial_config_file='test/test.json')
     try:
         c.verify_actions(['not_a_real_action'])
     except:
         pass
     else:
         self.assertEqual(0, 1, msg="verify_actions() didn't die on invalid action")
     c = config.BaseConfig(initial_config_file='test/test.json')
     returned_actions = c.verify_actions(c.all_actions)
     self.assertEqual(c.all_actions, returned_actions,
                      msg="returned actions from verify_actions() changed")
 def test_optional_config_files_override_value(self):
     c = config.BaseConfig(initial_config_file='test/test.py')
     c.parse_args([
         '--cfg', 'test/test_override.py,test/test_override2.py',
         '--opt-cfg', 'test/test_optional.py'
     ])
     self.assertEqual(c._config['opt_override'], "new stuff")
 def test_default_actions(self):
     c = config.BaseConfig(default_actions=self.default_actions,
                           all_actions=self.all_actions,
                           initial_config_file='test/test.json')
     self.assertEqual(self.default_actions,
                      c.get_actions(),
                      msg="default_actions broken")
 def test_optional_config_files_keep_string(self):
     c = config.BaseConfig(initial_config_file='test/test.py')
     c.parse_args([
         '--cfg', 'test/test_override.py,test/test_override2.py',
         '--opt-cfg', 'test/test_optional.py'
     ])
     self.assertEqual(c._config['keep_string'], "don't change me")
Beispiel #5
0
 def test_only_action(self):
     c = config.BaseConfig(default_actions=self.default_actions,
                           all_actions=self.all_actions,
                           initial_config_file='test/test.json')
     c.parse_args(args=['foo', '--a', '--e'])
     self.assertEqual(['a', 'e'], c.get_actions(),
                      msg="--ACTION broken")
Beispiel #6
0
 def test_no_action1(self):
     c = config.BaseConfig(default_actions=self.default_actions,
                           all_actions=self.all_actions,
                           initial_config_file='test/test.json')
     c.parse_args(args=['foo', '--no-action', 'a'])
     self.assertEqual(self.default_actions, c.get_actions(),
                      msg="--no-ACTION broken")
Beispiel #7
0
 def test_only_action(self):
     c = config.BaseConfig(
         default_actions=self.default_actions,
         all_actions=self.all_actions,
         initial_config_file="test/test.json",
     )
     c.parse_args(args=["foo", "--a", "--e"])
     self.assertEqual(["a", "e"], c.get_actions(), msg="--ACTION broken")
Beispiel #8
0
 def test_optional_config_files_keep_string(self):
     c = config.BaseConfig(initial_config_file="test/test.py")
     c.parse_args([
         "--cfg",
         "test/test_override.py,test/test_override2.py",
         "--opt-cfg",
         "test/test_optional.py",
     ])
     self.assertEqual(c._config["keep_string"], "don't change me")
Beispiel #9
0
 def test_optional_config_files_missing_config(self):
     c = config.BaseConfig(initial_config_file="test/test.py")
     c.parse_args([
         "--cfg",
         "test/test_override.py,test/test_override2.py",
         "--opt-cfg",
         "test/test_optional.py,does_not_exist.py",
     ])
     self.assertEqual(c._config["opt_override"], "new stuff")
Beispiel #10
0
 def test_multiple_config_files_override_list(self):
     c = config.BaseConfig(initial_config_file="test/test.py")
     c.parse_args(["--cfg", "test/test_override.py,test/test_override2.py"])
     self.assertEqual(c._config["override_list"], ["yay", "worked"])
Beispiel #11
0
 def test_python_config(self):
     c = config.BaseConfig(initial_config_file="test/test.py")
     config_dict = self._get_python_config()
     for key in config_dict.keys():
         self.assertEqual(config_dict[key], c._config[key])
Beispiel #12
0
 def test_multiple_config_files_override_dict(self):
     c = config.BaseConfig(initial_config_file='test/test.py')
     c.parse_args(['--cfg', 'test/test_override.py,test/test_override2.py'])
     self.assertEqual(c._config['override_dict'], {'yay': 'worked'})
Beispiel #13
0
 def test_json_config(self):
     c = config.BaseConfig(initial_config_file='test/test.json')
     content_dict = self._get_json_config()
     for key in content_dict.keys():
         self.assertEqual(content_dict[key], c._config[key])