def test_get_with_default_value(self):
     "Test the get method returns value if available or the the default."
     config = ConfigReader("tests/TestConfigReaderData")
     self.assertEqual(
         "some value", config.get("string_test", "default value"))
     self.assertEqual(
         "default value", config.get("i_dont_exist", "default value"))
 def test_get_handles_namespaced_keys(self):
     '''
     Test ConfigReader works with namespaced keys like, path.to.element
     '''
     config = ConfigReader("tests/TestConfigReaderData")
     value = config.get("bill-to.given")
     self.assertEqual(value, "Chris", "Value did not match expected.")
 def test_get_handles_namespaced_keys(self):
     '''
     Test ConfigReader works with namespaced keys like, path.to.element
     '''
     config = ConfigReader("tests/TestConfigReaderData")
     value = config.get("bill-to.given")
     self.assertEqual(value, "Chris", "Value did not match expected.")
 def test_get_returns_string_config_value(self):
     '''
     Test config value returned is expected value
     '''
     config = ConfigReader("tests/TestConfigReaderData")
     value = config.get("string_test")
     self.assertEqual(value, "some value", "Value did not match expected.")
 def test_get_returns_string_config_value(self):
     '''
     Test config value returned is expected value
     '''
     config = ConfigReader("tests/TestConfigReaderData")
     value = config.get("string_test")
     self.assertEqual(value, "some value", "Value did not match expected.")
 def test_get_handles_yaml_arrays(self):
     '''
     Test ConfigReader works with YAML arrays.
     '''
     config = ConfigReader("tests/TestConfigReaderData")
     self.assertEqual("dogs", config.get("list_test")[0])
     self.assertEqual("cats", config.get("list_test")[1])
     self.assertEqual("badgers", config.get("list_test")[2])
 def test_get_handles_yaml_arrays(self):
     '''
     Test ConfigReader works with YAML arrays.
     '''
     config = ConfigReader("tests/TestConfigReaderData")
     self.assertEqual("dogs", config.get("list_test")[0])
     self.assertEqual("cats", config.get("list_test")[1])
     self.assertEqual("badgers", config.get("list_test")[2])
    def test_get_with_cascaded_config_files(self):
        '''
        Test Config reader loaded up with multiple configs loads 
        the config preferences in order.
        '''

        config = ConfigReader("tests/TestConfig2;tests/TestConfig1")
        # should take config from config1
        self.assertEqual("hello", config.get("setting_from_config1"))
        # this will take the config from config2, which has precedence.
        self.assertEqual("beautiful", config.get("overwrite_setting"))
        # this will take the setting form config2.
        self.assertEqual("hi", config.get("setting_from_config2"))
    def test_get_with_cascaded_config_files(self):
        '''
        Test Config reader loaded up with multiple configs loads 
        the config preferences in order.
        '''

        config = ConfigReader("tests/TestConfig2;tests/TestConfig1")
        # should take config from config1
        self.assertEqual("hello", config.get("setting_from_config1"))
        # this will take the config from config2, which has precedence.
        self.assertEqual("beautiful", config.get("overwrite_setting"))
        # this will take the setting form config2.
        self.assertEqual("hi", config.get("setting_from_config2"))
Example #10
0
    def test_timeout_manager_uses_default_value_when_not_specified_in_config(self):
        "Test timeout manager returns value from our timeout settings."
        config_reader = ConfigReader('tests/TestConfig1')
        timeout_manager = TimeOutManager(config_reader=config_reader)

        self.assertEqual(5, timeout_manager.BRIEF)
        self.assertEqual(10, timeout_manager.SHORT)
        self.assertEqual(30, timeout_manager.NORMAL)
        self.assertEqual(60, timeout_manager.LONG)
        self.assertEqual(300, timeout_manager.EPIC)
 def setUp(self):
     config_reader = ConfigReader('tests/timeout-manager-testfile')
     self.timeout_manager = TimeOutManager(config_reader=config_reader)
 def test_get_with_missing_key_and_no_default(self):
     "An error should be thrown if the key is missing and no default provided."
     config = ConfigReader("tests/TestConfig2;tests/TestConfig1")
     # should take config from config1
     self.assertRaises(KeyError, config.get, "setting_that_doesnt_exist")
Example #13
0
 def __init__(self):
     cr = ConfigReader('db')
     self.conn = psycopg2.connect(dbname=cr.get("postgre_dbname"), user=cr.get("postgre_user"), host=cr.get("postgre_host"), port=cr.get("postgre_port"), password=cr.get("postgre_password"))
     self.cur = self.conn.cursor(cursor_factory=extras.RealDictCursor)
 def test_get_with_default_value(self):
     "Test the get method returns value if available or the the default."
     config = ConfigReader("tests/TestConfigReaderData")
     self.assertEqual("some value", config.get("string_test", "default value"))
     self.assertEqual("default value", config.get("i_dont_exist", "default value"))