def test_init_reader_with_str_as_value(self): with self.assertRaises(TypeError): UrlConfig('http://config.json', reader='non reader')
def test_init_reader_with_reader_value(self): reader = JsonReader() config = UrlConfig('http://config.json', reader=reader) self.assertEqual(reader, config.reader)
def test_get_reader_with_default_value(self): config = UrlConfig('http://config.json') self.assertIsNone(config.reader)
def test_init_url_with_str_value(self): config = UrlConfig('http://config.json') self.assertEqual('http://config.json', config.url)
def test_load_real_url(self): config = UrlConfig('http://date.jsontest.com/') config.load() self.assertIsNotNone(config['time'])
def test_init_url_with_int_value(self): with self.assertRaises(TypeError): UrlConfig(url=123)
from central.config.url import UrlConfig config = UrlConfig('http://date.jsontest.com/') config.load() print(config.get('time')) print(config.get('milliseconds_since_epoch')) print(config.get('date'))