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)
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)
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")
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")
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")
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")
def test_example_test_file_not_exists(self): with self.assertRaises(ConfigDoesNotFoundException): config = ConfFile(path="path/not/exist.yml")
def test_example_test_config_not_exixsts(self): with self.assertRaises(ConfigDoesNotFoundException): config = ConfFile()
def test_dictionary_attribute_not_exists(self): config = ConfFile(config={"test-1": "a"}) with self.assertRaises(AttrDoesNotExistException): config.not_exist
def test_dictionary_normal_key(self): config = ConfFile(config={"test-1": "a", "test_2": "b"}) self.assertEqual(config.test_2, "b")
def test_example_test_file_from_env(self): config = ConfFile() self.assertEqual(config.pyms.config.test_var, "general")
def test_empty_conf_three_levels(self): config = ConfFile(empty_init=True) self.assertEqual(config.my_ms.level_two.level_three, {})
def test_empty_conf(self): config = ConfFile(empty_init=True) self.assertEqual(config.my_ms, {})
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")