示例#1
0
 def test_copy(self):
     path = JsonPath("/foo/bar")
     copy = path.copy()
     path.append("baz")
     self.assertEqual(path.components, ["foo", "bar", "baz"])
     self.assertEqual(copy.components, ["foo", "bar"])
示例#2
0
 def test_extend_seq(self):
     path = JsonPath("/foo/bar")
     path.extend(["baz", "~bop/"])
     self.assertEqual(path.components, ["foo", "bar", "baz", "~0bop~1"])
示例#3
0
 def test_extend_error(self):
     path = JsonPath("/foo/bar")
     with self.assertRaises(TypeError):
         path.extend({})
示例#4
0
 def test_extend_path_obj(self):
     path = JsonPath("/foo/bar")
     path.extend(JsonPath("/baz/bop"))
     self.assertEqual(path.components, ["foo", "bar", "baz", "bop"])
示例#5
0
 def test_append(self):
     path = JsonPath("/foo/bar")
     path.append("baz")
     self.assertEqual(path.components, ["foo", "bar", "baz"])
     path.append("/obj~")
     self.assertEqual(path.components, ["foo", "bar", "baz", "~1obj~0"])
示例#6
0
 def test_create_split(self):
     individual = JsonPath("foo", "bar")
     self.assertEqual(individual.components, ["foo", "bar"])
     escapes = JsonPath("/foo", "~bar")
     self.assertEqual(escapes.components, ["~1foo", "~0bar"])
示例#7
0
 def test_create_path(self):
     complete = JsonPath("/foo/bar")
     self.assertEqual(complete.components, ["foo", "bar"])
示例#8
0
 def test_create_empty(self):
     empty = JsonPath()
     self.assertEqual(str(empty), "/")