Пример #1
0
 def test_it_should_raise_exception_for_an_inexistent_config_value_without_specify_a_default_value(self):
     config = Config()
     config.put("some_key", "some_value")
     try:
         config.get("ANOTHER_KEY")
     except Exception, e:
         self.assertEqual("invalid key ('another_key')", str(e))
Пример #2
0
 def test_it_should_accept_non_empty_string_and_false_as_default_value(
         self):
     config = Config()
     config.put("some_key", "some_value")
     self.assertEqual(None, config.get("ANOTHER_KEY", None))
     self.assertEqual("", config.get("ANOTHER_KEY", ""))
     self.assertEqual(False, config.get("ANOTHER_KEY", False))
Пример #3
0
 def test_it_should_raise_exception_for_an_inexistent_config_value_without_specify_a_default_value(self):
     config = Config()
     config.put("some_key", "some_value")
     try:
         config.get("ANOTHER_KEY")
     except Exception, e:
         self.assertEqual("invalid key ('another_key')", str(e))
Пример #4
0
 def test_it_should_transform_keys_to_lower_case(self):
     config = Config()
     config.put("sOmE_kEy", "original_value")
     self.assertEqual("original_value", config.get("SoMe_KeY"))
     config.update("sOMe_kEy", "new_value")
     self.assertEqual("new_value", config.get("some_KEY"))
     config.remove("SOME_KEY")
     self.assertRaises(Exception, config.get, "sOMe_KEY")
Пример #5
0
 def test_it_should_transform_keys_to_lower_case(self):
     config = Config()
     config.put("sOmE_kEy", "original_value")
     self.assertEqual("original_value", config.get("SoMe_KeY"))
     config.update("sOMe_kEy", "new_value")
     self.assertEqual("new_value", config.get("some_KEY"))
     config.remove("SOME_KEY")
     self.assertRaises(Exception, config.get, "sOMe_KEY")
Пример #6
0
 def test_it_should_update_value_to_a_existing_key_keeping_original_value_if_new_value_is_none_false_or_empty_string(self):
     config = Config()
     config.put("some_key", "original_value")
     config.update("some_key", None)
     self.assertEqual("original_value", config.get("some_key"))
     config.update("some_key", False)
     self.assertEqual("original_value", config.get("some_key"))
     config.update("some_key", "")
     self.assertEqual("original_value", config.get("some_key"))
Пример #7
0
 def test_it_should_update_value_to_a_existing_key_keeping_original_value_if_new_value_is_none_false_or_empty_string(self):
     config = Config()
     config.put("some_key", "original_value")
     config.update("some_key", None)
     self.assertEqual("original_value", config.get("some_key"))
     config.update("some_key", False)
     self.assertEqual("original_value", config.get("some_key"))
     config.update("some_key", "")
     self.assertEqual("original_value", config.get("some_key"))
Пример #8
0
 def test_it_should_update_value_to_a_existing_key(self):
     config = Config()
     config.put("some_key", "original_value")
     config.update("some_key", "some_value")
     self.assertEqual("some_value", config.get("some_key"))
Пример #9
0
 def test_it_should_accept_non_empty_string_and_false_as_default_value(self):
     config = Config()
     config.put("some_key", "some_value")
     self.assertEqual(None, config.get("ANOTHER_KEY", None))
     self.assertEqual("", config.get("ANOTHER_KEY", ""))
     self.assertEqual(False, config.get("ANOTHER_KEY", False))
Пример #10
0
 def test_it_should_return_default_value_for_an_inexistent_config_value(self):
     config = Config()
     config.put("some_key", "some_value")
     self.assertEqual("default_value", config.get("another_key", "default_value"))
Пример #11
0
 def test_it_should_accept_initial_values_as_configuration(self):
     config = Config({"some_key": "some_value"})
     self.assertEqual("some_value", config.get("some_key"))
Пример #12
0
 def test_it_should_return_previous_saved_config_values(self):
     config = Config()
     config.put("some_key", "some_value")
     self.assertEqual("some_value", config.get("some_key"))
Пример #13
0
 def test_it_should_update_value_to_a_existing_key(self):
     config = Config()
     config.put("some_key", "original_value")
     config.update("some_key", "some_value")
     self.assertEqual("some_value", config.get("some_key"))
Пример #14
0
 def test_it_should_return_default_value_for_an_inexistent_config_value(
         self):
     config = Config()
     config.put("some_key", "some_value")
     self.assertEqual("default_value",
                      config.get("another_key", "default_value"))
Пример #15
0
 def test_it_should_accept_initial_values_as_configuration(self):
     config = Config({"some_key": "some_value"})
     self.assertEqual("some_value", config.get("some_key"))
Пример #16
0
 def test_it_should_return_previous_saved_config_values(self):
     config = Config()
     config.put("some_key", "some_value")
     self.assertEqual("some_value", config.get("some_key"))