def test_init_without_auth(self): yaml = YamlConfigurationFile() self.assertIsNotNone(yaml) yaml.load_from_text( """ rest: host: 127.0.0.1 port: 5000 api: /api/rest/v1.0/ask debug: false workers: 4 use_api_keys: false api_key_file: apikeys.txt """, ConsoleConfiguration(), ".") rest_config = RestConfiguration("rest") rest_config.load_configuration(yaml, ".") self.assertEqual("127.0.0.1", rest_config.host) self.assertEqual(5000, rest_config.port) self.assertEqual('/api/rest/v1.0/ask', rest_config.api) self.assertEqual(False, rest_config.debug) self.assertEqual(False, rest_config.use_api_keys) self.assertEqual("apikeys.txt", rest_config.api_key_file) self.assertIsNone(rest_config.authorization)
def test_init_no_values(self): yaml = YamlConfigurationFile() self.assertIsNotNone(yaml) yaml.load_from_text(""" rest: """, ConsoleConfiguration(), ".") rest_config = RestConfiguration("rest") rest_config.load_configuration(yaml, ".") self.assertEqual("0.0.0.0", rest_config.host) self.assertEqual(80, rest_config.port) self.assertEqual(False, rest_config.debug) self.assertEqual(False, rest_config.use_api_keys)
def test_init(self): yaml = YamlConfigurationFile() self.assertIsNotNone(yaml) yaml.load_from_text(""" rest: host: 127.0.0.1 port: 5000 debug: false workers: 4 use_api_keys: false api_key_file: apikeys.txt """, ConsoleConfiguration(), ".") rest_config = RestConfiguration("rest") rest_config.load_configuration(yaml, ".") self.assertEqual("127.0.0.1", rest_config.host) self.assertEqual(5000, rest_config.port) self.assertEqual(False, rest_config.debug) self.assertEqual(False, rest_config.use_api_keys) self.assertEqual("apikeys.txt", rest_config.api_key_file)