Exemplo n.º 1
0
 def test_truediv(self):
     self.assertEqual(pychirp.Path('/Test/tmp'),
                      pychirp.Path('/Test') / pychirp.Path('tmp'))
     self.assertEqual(pychirp.Path('/Test/tmp'),
                      pychirp.Path('/Test') / 'tmp')
     self.assertRaises(pychirp.BadPath,
                       lambda: pychirp.Path('/Test') / pychirp.Path('/tmp'))
Exemplo n.º 2
0
 def test_json_overrides(self):
     cfg = pychirp.Configuration([
         'test.py', 'config_a.json', '--json={"my-age": 42}', '-j',
         '{"my-id": 55}', '--json={"chirp": {"location": "/Somewhere"}}',
         '--location=/Home'
     ])
     self.assertEqual(42, cfg.config['my-age'])
     self.assertEqual(55, cfg.config['my-id'])
     self.assertEqual(pychirp.Path('/Home'), cfg.location)
Exemplo n.º 3
0
 def test_command_line_override(self):
     cfg = pychirp.Configuration([
         'test.py', 'config_a.json', '--connection_target=my-host:1234',
         '--connection_timeout=0.555', '-i', 'Dude', '--location=/Home'
     ])
     self.assertEqual(pychirp.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)
Exemplo n.º 4
0
 def test_bad_path(self):
     self.assertRaises(pychirp.BadPath, lambda: pychirp.Path('//'))
     self.assertRaises(pychirp.BadPath, lambda: pychirp.Path('/tmp//'))
     self.assertRaises(pychirp.BadPath, lambda: pychirp.Path('tmp//'))
     self.assertRaises(pychirp.BadPath, lambda: pychirp.Path('a//b'))
Exemplo n.º 5
0
 def test_is_root(self):
     self.assertTrue(pychirp.Path('/').is_root)
     self.assertFalse(pychirp.Path('/Test').is_root)
     self.assertFalse(pychirp.Path('').is_root)
Exemplo n.º 6
0
 def test_is_absolute(self):
     self.assertTrue(pychirp.Path('/Test').is_absolute)
     self.assertFalse(pychirp.Path('Test').is_absolute)
Exemplo n.º 7
0
 def test_clear(self):
     path = pychirp.Path('/Test')
     path.clear()
     self.assertEqual(pychirp.Path(), path)
Exemplo n.º 8
0
 def test_eq(self):
     self.assertEqual(pychirp.Path('/Test/tmp'), pychirp.Path('/Test/tmp'))
     self.assertEqual(pychirp.Path('/Test/tmp'), '/Test/tmp')
Exemplo n.º 9
0
 def test_len(self):
     self.assertEqual(5, len(pychirp.Path('/Test')))
Exemplo n.º 10
0
 def test_str(self):
     self.assertEqual('/Test', str(pychirp.Path('/Test')))
Exemplo n.º 11
0
 def test_empty_configuration(self):
     cfg = pychirp.Configuration(argv=None)
     self.assertEquals(pychirp.Path(), cfg.location)
     self.assertIsNone(cfg.connection_target)
     self.assertIsNone(cfg.connection_timeout)
     self.assertIsNone(cfg.connection_identification)
Exemplo n.º 12
0
 def test_config_file_priority(self):
     cfg = pychirp.Configuration(
         ['test.py', 'config_a.json', 'config_b.json'])
     self.assertEqual(pychirp.Path('/Pudding'), cfg.location)
     self.assertIsNone(cfg.connection_target)
Exemplo n.º 13
0
 def test_config_file(self):
     cfg = pychirp.Configuration(['test.py', 'config_a.json'])
     self.assertEqual(pychirp.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)
Exemplo n.º 14
0
 def test_update(self):
     cfg = pychirp.Configuration(['test.py', 'config_a.json'])
     cfg.update('{"chirp": {"location": "/Home"}}')
     self.assertEqual(pychirp.Path("/Home"), cfg.location)
     self.assertRaises(pychirp.BadConfiguration, lambda: cfg.update('{'))