コード例 #1
0
 def test_command_line_override(self):
     cfg = yogi.Configuration(['test.py', make_config_path('a'), '--connection_target=my-host:1234',
                                  '--connection_timeout=0.555', '-i', 'Dude', '--location=/Home'])
     self.assertEqual(yogi.Path('/Home'), cfg.location)
     self.assertEqual('my-host:1234', cfg.connection_target)
     self.assertAlmostEqual(0.555, cfg.connection_timeout)
     self.assertEqual('Dude', cfg.connection_identification)
コード例 #2
0
 def test_json_overrides(self):
     cfg = yogi.Configuration(['test.py', make_config_path('a'), '--json={"my-age": 42}', '-j', '{"my-id": 55}',
                                  '--json={"yogi": {"location": "/Somewhere"}}', '--location=/Home'])
     self.assertEqual(42, cfg.config['my-age'])
     self.assertEqual(55, cfg.config['my-id'])
     self.assertEqual(yogi.Path('/Home'), cfg.location)
コード例 #3
0
 def test_config_file_priority(self):
     cfg = yogi.Configuration(['test.py', make_config_path('a'), make_config_path('b')])
     self.assertEqual(yogi.Path('/Pudding'), cfg.location)
     self.assertIsNone(cfg.connection_target)
コード例 #4
0
 def test_update(self):
     cfg = yogi.Configuration(['test.py', make_config_path('a')])
     cfg.update('{"yogi": {"location": "/Home"}}')
     self.assertEqual(yogi.Path("/Home"), cfg.location)
     self.assertRaises(yogi.BadConfiguration, lambda: cfg.update('{'))
コード例 #5
0
 def test_config_file(self):
     cfg = yogi.Configuration(['test.py', make_config_path('a')])
     self.assertEqual(yogi.Path('/Test'), cfg.location)
     self.assertEqual('localhost:12345', cfg.connection_target)
     self.assertAlmostEqual(1.234, cfg.connection_timeout)
     self.assertEqual('Hello World', cfg.connection_identification)
コード例 #6
0
ファイル: test_path.py プロジェクト: yohummus/yogi
 def test_is_root(self):
     self.assertTrue(yogi.Path('/').is_root)
     self.assertFalse(yogi.Path('/Test').is_root)
     self.assertFalse(yogi.Path('').is_root)
コード例 #7
0
 def test_empty_configuration(self):
     cfg = yogi.Configuration(argv=None)
     self.assertEqual(yogi.Path('/'), cfg.location)
     self.assertIsNone(cfg.connection_target)
     self.assertIsNone(cfg.connection_timeout)
     self.assertIsNone(cfg.connection_identification)
コード例 #8
0
ファイル: test_path.py プロジェクト: yohummus/yogi
 def test_clear(self):
     path = yogi.Path('/Test')
     path.clear()
     self.assertEqual(yogi.Path(), path)
コード例 #9
0
ファイル: test_path.py プロジェクト: yohummus/yogi
 def test_is_absolute(self):
     self.assertTrue(yogi.Path('/Test').is_absolute)
     self.assertFalse(yogi.Path('Test').is_absolute)
コード例 #10
0
ファイル: test_path.py プロジェクト: yohummus/yogi
 def test_truediv(self):
     self.assertEqual(yogi.Path('/Test/tmp'), yogi.Path('/Test') / yogi.Path('tmp'))
     self.assertEqual(yogi.Path('/Test/tmp'), yogi.Path('/Test') / 'tmp')
     self.assertRaises(yogi.BadPath, lambda: yogi.Path('/Test') / yogi.Path('/tmp'))
コード例 #11
0
ファイル: test_path.py プロジェクト: yohummus/yogi
 def test_eq(self):
     self.assertEqual(yogi.Path('/Test/tmp'), yogi.Path('/Test/tmp'))
     self.assertEqual(yogi.Path('/Test/tmp'), '/Test/tmp')
コード例 #12
0
ファイル: test_path.py プロジェクト: yohummus/yogi
 def test_len(self):
     self.assertEqual(5, len(yogi.Path('/Test')))
コード例 #13
0
ファイル: test_path.py プロジェクト: yohummus/yogi
 def test_str(self):
     self.assertEqual('/Test', str(yogi.Path('/Test')))
コード例 #14
0
ファイル: test_path.py プロジェクト: yohummus/yogi
 def test_bad_path(self):
     self.assertRaises(yogi.BadPath, lambda: yogi.Path('//'))
     self.assertRaises(yogi.BadPath, lambda: yogi.Path('/tmp//'))
     self.assertRaises(yogi.BadPath, lambda: yogi.Path('tmp//'))
     self.assertRaises(yogi.BadPath, lambda: yogi.Path('a//b'))