def test_create_delete_workspace(self): y = Zenoh.login(ZSERVER) admin = y.admin() stid = '123' admin.add_storage(stid, {'selector': '/myzenoh/**'}) time.sleep(1) # TODO remove workspace = y.workspace('/myzenoh') self.assertEqual(workspace.path, Path('/myzenoh')) admin.remove_storage(stid) y.logout()
def test_path_len(self): s = '/this/is/a/path' p1 = Path('/this/is/a/path') self.assertEqual(len(s), len(p1))
def test_path_repr(self): p1 = Path('/this/is/a/path') self.assertEqual(repr(p1), '/this/is/a/path')
def test_path_hash(self): p1 = Path('/this/is/a/path') self.assertEqual(hash(p1), hash('/this/is/a/path'))
def test_path_not_equal(self): p1 = Path('/this/is/a/path') p2 = '/this/is/not/a/path' self.assertNotEqual(p1, p2)
def test_path_equal(self): p1 = Path('/this/is/a/path') p2 = Path('/this/is/a/path') self.assertEqual(p1, p2)
def test_to_path(self): p = '/test' p2 = Path('/test') self.assertEqual(Path.to_path(p), Path('/test')) self.assertEqual(Path.to_path(p2), Path('/test'))
def test_path_prefix(self): p = Path('/this/is/a/path/with/a/prefix') self.assertTrue(p.is_prefix('/this/is/a/path')) self.assertFalse(p.is_prefix('/that/is/a/path'))
def test_path_check_absolute_ko(self): path = Path('this/is/a/relative/path') self.assertFalse(path.is_absolute())
def test_path_check_absolute_ok(self): p = Path('/this/is/a/absoliute/path') self.assertTrue(p.is_absolute())
def test_path_check_ok(self): p = Path('/this/is/a/path') self.assertEqual('/this/is/a/path', p.to_string())
def test_path_remove_prefix_no_prefix(self): p = Path('/this/is/a/path/with/a/prefix') p.remove_prefix('/that/is/a/path') self.assertEqual(p.to_string(), '/this/is/a/path/with/a/prefix')
def test_selector_not_equal(self): s1 = Selector('/this/is/a/**?x>10(x.y.z=100)#field') s2 = Path('/this/is/a/path') self.assertNotEqual(s1, s2)
def test_selector_complete(self): s = Selector('/this/is/a/**?x>10(x.y.z=100)#field') self.assertEqual(Path('/this/is/a/'), s.get_prefix()) self.assertEqual('field', s.get_fragment()) self.assertEqual('x.y.z=100', s.get_properties()) self.assertEqual('x>10', s.get_predicate())
def test_selector_with_fragment(self): s = Selector('/this/is/a/selector#field') self.assertEqual(Path('/this/is/a/selector'), s.get_prefix()) self.assertEqual('field', s.get_fragment())
def test_selector_with_predicate(self): s = Selector('/this/is/a/selector?x>10') self.assertEqual(Path('/this/is/a/selector'), s.get_prefix()) self.assertEqual('x>10', s.get_predicate())