本文整理匯總了Python中galicaster.core.conf.Conf.get_json方法的典型用法代碼示例。如果您正苦於以下問題:Python Conf.get_json方法的具體用法?Python Conf.get_json怎麽用?Python Conf.get_json使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類galicaster.core.conf.Conf
的用法示例。
在下文中一共展示了Conf.get_json方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestFunctions
# 需要導入模塊: from galicaster.core.conf import Conf [as 別名]
# 或者: from galicaster.core.conf.Conf import get_json [as 別名]
#.........這裏部分代碼省略.........
self.assertEqual(self.conf.get_list('s', 'k'), ['1', '2', '3', '4', '5', '6'])
self.conf.set('s', 'k', 'one two three')
self.assertEqual(self.conf.get_list('s', 'k'), ['one', 'two', 'three'])
def test_get_choice(self):
self.assertEqual(self.conf.get_choice('s', 'k', ['1','2','3'], '2'), '2')
self.conf.set('s', 'k', '1')
self.assertEqual(self.conf.get_choice('s', 'k', ['1','2','3']), '1')
self.conf.set('s', 'k', 'TEST')
self.assertEqual(self.conf.get_choice('s', 'k', ['1','2','3', 'test']), 'test')
def test_get_choice_uppercase(self):
self.assertEqual(self.conf.get_choice_uppercase('s', 'k', ['1','2','3'], '2'), '2')
self.conf.set('s', 'k', '1')
self.assertEqual(self.conf.get_choice_uppercase('s', 'k', ['1','2','3']), '1')
self.conf.set('s', 'k', 'test')
self.assertEqual(self.conf.get_choice_uppercase('s', 'k', ['1','2','3', 'TEST']), 'TEST')
def test_get_dict(self):
self.assertEqual(self.conf.get_dict('s', 'k'), {})
self.conf.set('s', 'k', 'k1:v1;k2:v2;k3:v3')
self.assertEqual(self.conf.get_dict('s', 'k'), {'k1': 'v1', 'k2': 'v2', 'k3': 'v3'})
def test_get_json(self):
self.assertEqual(self.conf.get_json('s', 'k'), {})
self.conf.set('s', 'k', '{"a":{"a1":"value1", "a2":"value2"},"b": "value3"}')
self.assertEqual(self.conf.get_json('s', 'k'), {"a": {"a1": "value1", "a2": "value2"}, "b": "value3"})
def test_track_property(self):
track = Track()
track.name = 'name'
self.assertEqual(track.name, 'name')
self.assertEqual(track['name'], 'name')
def test_get_hostname(self):
conf = Conf(self.conf_file)
conf.set('config', 'ingest', None)
conf.set('basic', 'admin', 'True')
conf.set('ingest', 'hostname', None)
self.assertEqual('GCMobile-' + socket.gethostname(), conf.get_hostname())
self.assertEqual(1, len(conf.get_tracks_in_oc_dict()))
self.assertEqual({'capture.device.names': 'defaults'}, conf.get_tracks_in_oc_dict())
conf.set('basic', 'admin', 'False')
conf.set('ingest', 'hostname', None)
self.assertEqual('GC-' + socket.gethostname(), conf.get_hostname())
name = "123456_654321"
conf.set('ingest', 'hostname', name)
self.assertEqual(name, conf.get_hostname())
a = conf.remove_option('ingest', 'hostname')
def test_get_ip_address(self):
valid = True