def test_read_configuration_file_empty(self): local_env = test_support.EnvironmentVarGuard() local_env.unset("HELLOWORLD_SPRINGER_APP_TIMEOUT") local_env.unset("HELLOWORLD_SPRINGER_APP_DATE_ENDPOINT") with local_env, patch.object(builtins, "open", mock_open(read_data="")): config.load_config() self.assertNotIn("timeout", config.configuration) self.assertNotIn("date_endpoint", config.configuration)
def test_read_configuration_both_file_and_env_defined(self): with self.env, patch("os.path.isfile", return_value=True), patch.object( builtins, "open", mock_open(read_data=configuration_file_content) ): config.load_config() self.assertEqual(config.configuration["timeout"], "5") self.assertEqual(config.configuration["date_endpoint"], "http://test.env.com/")
def test_read_configuration_only_file_defined(self): local_env = test_support.EnvironmentVarGuard() local_env.unset("HELLOWORLD_SPRINGER_APP_TIMEOUT") local_env.unset("HELLOWORLD_SPRINGER_APP_DATE_ENDPOINT") with local_env, patch("os.path.isfile", return_value=True), patch.object( builtins, "open", mock_open(read_data=configuration_file_content) ): config.load_config() self.assertEqual(config.configuration["timeout"], 1) self.assertEqual(config.configuration["date_endpoint"], "http://test.file.com/")