コード例 #1
0
ファイル: test_config.py プロジェクト: oadiazm/pyms
 def test_equal_instances_ok(self):
     config1 = ConfFile(
         config={"test-1": {
             "test-1-1": "a",
             "test_1-2": "b"
         }})
     config2 = ConfFile(
         config={"test-1": {
             "test-1-1": "a",
             "test_1-2": "b"
         }})
     self.assertEqual(config1, config2)
コード例 #2
0
    def test_equal_instances_ko(self):
        config = ConfFile(config={"test-1": {"test-1-1": "a"}})
        no_valid_type = ConfigDoesNotFoundException

        result = config == no_valid_type

        self.assertEqual(result, False)
コード例 #3
0
ファイル: test_config.py プロジェクト: oadiazm/pyms
 def test_dictionary_recursive_dict_normal_key_dinamyc(self):
     config = ConfFile(config={
         "test-1": {
             "test-1-1": "a",
             "test_1-2": "b"
         },
         "test_2": "c"
     })
     self.assertEqual(getattr(config, "test_1.test_1_2"), "b")
コード例 #4
0
ファイル: test_config.py プロジェクト: oadiazm/pyms
 def test_dictionary_recursive_dict_normal_key(self):
     config = ConfFile(config={
         "test-1": {
             "test-1-1": "a",
             "test_1-2": "b"
         },
         "test_2": "c"
     })
     self.assertEqual(config.test_1.test_1_2, "b")
コード例 #5
0
ファイル: test_config.py プロジェクト: oadiazm/pyms
 def test_dictionary_recursive_dict_replace_key(self):
     config = ConfFile(config={
         "test-1": {
             "test-1-1": "a",
             "test_1-2": "b"
         },
         "test_2": "b"
     })
     self.assertEqual(config.test_1.test_1_1, "a")
コード例 #6
0
 def test_example_test_json_file(self):
     config = ConfFile(path=os.path.join(self.BASE_DIR, "config-tests.json"))
     self.assertEqual(config.pyms.config.test_var, "general")
コード例 #7
0
 def test_example_test_file_not_exists(self):
     with self.assertRaises(ConfigDoesNotFoundException):
         config = ConfFile(path="path/not/exist.yml")
コード例 #8
0
 def test_example_test_config_not_exixsts(self):
     with self.assertRaises(ConfigDoesNotFoundException):
         config = ConfFile()
コード例 #9
0
 def test_dictionary_attribute_not_exists(self):
     config = ConfFile(config={"test-1": "a"})
     with self.assertRaises(AttrDoesNotExistException):
         config.not_exist
コード例 #10
0
 def test_dictionary_normal_key(self):
     config = ConfFile(config={"test-1": "a", "test_2": "b"})
     self.assertEqual(config.test_2, "b")
コード例 #11
0
 def test_example_test_file_from_env(self):
     config = ConfFile()
     self.assertEqual(config.pyms.config.test_var, "general")
コード例 #12
0
 def test_empty_conf_three_levels(self):
     config = ConfFile(empty_init=True)
     self.assertEqual(config.my_ms.level_two.level_three, {})
コード例 #13
0
 def test_empty_conf(self):
     config = ConfFile(empty_init=True)
     self.assertEqual(config.my_ms, {})
コード例 #14
0
 def test_example_test_yaml_file(self):
     config = ConfFile(path=os.path.join(self.BASE_DIR, "config-tests.yml"))
     self.assertEqual(config.my_ms.test_var, "general")