def test_match_first_variable(self): tree = {"$anything": [{"$releasever": [{"bar": [{PATH_END: None}]}]}]} data = open(DATA, "rb").read() pt = PathTree(data) # just swap out the pre-cooked data with out with pt.path_tree = tree self.assertTrue(pt.match_path("/foo/path/bar")) self.assertFalse(pt.match_path("/foo/path/abc"))
def test_match_first_variable(self): tree = {'$anything': [{'$releasever': [{'bar': [{PATH_END: None}]}]}]} data = open(DATA, 'rb').read() pt = PathTree(data) # just swap out the pre-cooked data with out with pt.path_tree = tree self.assertTrue(pt.match_path('/foo/path/bar')) self.assertFalse(pt.match_path('/foo/path/abc'))
def test_match_variable(self): tree = {'foo': [{'$releasever': [{'bar':[{PATH_END: None}]}]}]} data = open(DATA).read() pt = PathTree(data) # just swap out the pre-cooked data with out with pt.path_tree = tree self.assertTrue(pt.match_path('/foo/path/bar')) self.assertFalse(pt.match_path('/foo/path/abc'))
def test_match_path_listing(self): tree = {'foo': [{'path': [{'bar': [{PATH_END: None}]}]}]} data = open(DATA, 'rb').read() pt = PathTree(data) pt.path_tree = tree self.assertTrue(pt.match_path('/foo/path/bar/listing')) self.assertTrue(pt.match_path('/foo/path/listing')) self.assertTrue(pt.match_path('/foo/listing')) self.assertFalse(pt.match_path('/foo/path/alfred')) self.assertFalse(pt.match_path('/foo/path/listing/for/alfred'))
def test_match_path_listing(self): tree = {'foo': [{'path': [{'bar':[{PATH_END: None}]}]}]} data = open(DATA).read() pt = PathTree(data) pt.path_tree = tree self.assertTrue(pt.match_path('/foo/path/bar/listing')) self.assertTrue(pt.match_path('/foo/path/listing')) self.assertTrue(pt.match_path('/foo/listing')) self.assertFalse(pt.match_path('/foo/path/alfred')) self.assertFalse(pt.match_path('/foo/path/listing/for/alfred'))
def test_match_path_listing(self): tree = {"foo": [{"path": [{"bar": [{PATH_END: None}]}]}]} data = open(DATA, "rb").read() pt = PathTree(data) pt.path_tree = tree self.assertTrue(pt.match_path("/foo/path/bar/listing")) self.assertTrue(pt.match_path("/foo/path/listing")) self.assertTrue(pt.match_path("/foo/listing")) self.assertFalse(pt.match_path("/foo/path/alfred")) self.assertFalse(pt.match_path("/foo/path/listing/for/alfred"))
def test_match_different_variables(self): tree1 = {'foo': [{'$releasever': [{'bar':[{PATH_END: None}]}], 'jarjar': [{'binks':[{PATH_END: None}]}]}]} tree2 = {'foo': [{'jarjar': [{'binks':[{PATH_END: None}]}], '$releasever': [{'bar':[{PATH_END: None}]}]}]} tree3 = {'foo': [{'$releasever': [{'bar':[{PATH_END: None}]}]}, {'jarjar': [{'binks':[{PATH_END: None}]}]}]} tree4 = {'foo': [{'jarjar': [{'binks':[{PATH_END: None}]}]}, {'$releasever': [{'bar':[{PATH_END: None}]}]}]} trees = [tree1, tree2, tree3, tree4] data = open(DATA).read() pt = PathTree(data) #just swap out the pre-cooked data with out with for tree in trees: pt.path_tree = tree self.assertTrue(pt.match_path('/foo/path/bar')) self.assertFalse(pt.match_path('/foo/path/abc')) self.assertFalse(pt.match_path('/foo/path/abc')) self.assertTrue(pt.match_path('/foo/jarjar/binks')) self.assertTrue(pt.match_path('/foo/jarjar/bar')) self.assertFalse(pt.match_path('/foo/jarjar/notbinks'))
def test_match_path(self): data = open(DATA, 'rb').read() pt = PathTree(data) self.assertTrue(pt.match_path('/foo/path')) self.assertTrue(pt.match_path('/foo/path/')) # the '2' should match against "$releasever" self.assertTrue(pt.match_path('/foo/path/always/2')) self.assertTrue(pt.match_path('/foo/path/bar')) self.assertTrue(pt.match_path('/foo/path/bar/a/b/c')) self.assertFalse(pt.match_path('/foo')) self.assertFalse(pt.match_path('/bar'))
def test_match_path(self): data = open(DATA).read() pt = PathTree(data) self.assertTrue(pt.match_path('/foo/path')) self.assertTrue(pt.match_path('/foo/path/')) # the '2' should match against "$releasever" self.assertTrue(pt.match_path('/foo/path/always/2')) self.assertTrue(pt.match_path('/foo/path/bar')) self.assertTrue(pt.match_path('/foo/path/bar/a/b/c')) self.assertFalse(pt.match_path('/foo')) self.assertFalse(pt.match_path('/bar'))
def test_match_path(self): data = open(DATA, "rb").read() pt = PathTree(data) self.assertTrue(pt.match_path("/foo/path")) self.assertTrue(pt.match_path("/foo/path/")) # the '2' should match against "$releasever" self.assertTrue(pt.match_path("/foo/path/always/2")) self.assertTrue(pt.match_path("/foo/path/bar")) self.assertTrue(pt.match_path("/foo/path/bar/a/b/c")) self.assertFalse(pt.match_path("/foo")) self.assertFalse(pt.match_path("/bar"))
def test_match_different_variables(self): tree1 = { "foo": [{ "$releasever": [{ "bar": [{ PATH_END: None }] }], "jarjar": [{ "binks": [{ PATH_END: None }] }] }] } tree2 = { "foo": [{ "jarjar": [{ "binks": [{ PATH_END: None }] }], "$releasever": [{ "bar": [{ PATH_END: None }] }] }] } tree3 = { "foo": [ { "$releasever": [{ "bar": [{ PATH_END: None }] }] }, { "jarjar": [{ "binks": [{ PATH_END: None }] }] }, ] } tree4 = { "foo": [ { "jarjar": [{ "binks": [{ PATH_END: None }] }] }, { "$releasever": [{ "bar": [{ PATH_END: None }] }] }, ] } trees = [tree1, tree2, tree3, tree4] data = open(DATA, "rb").read() pt = PathTree(data) # just swap out the pre-cooked data with out with for tree in trees: pt.path_tree = tree self.assertTrue(pt.match_path("/foo/path/bar")) self.assertFalse(pt.match_path("/foo/path/abc")) self.assertFalse(pt.match_path("/foo/path/abc")) self.assertTrue(pt.match_path("/foo/jarjar/binks")) self.assertTrue(pt.match_path("/foo/jarjar/bar")) self.assertFalse(pt.match_path("/foo/jarjar/notbinks"))