def test_aggregate(self): data = self.stringify_json([{ "a": ldictify([1, 2, 3]), "b": ldictify([4, 5, 6]) }]) m = test_execute("(aggregate (json_literal %s))" % data) m = execute.materialize_walk(m) m = tuple(m[0].values())[0] self.assertEqual(set(m), set(ldictify([1, 2, 3, 4, 5, 6])))
def test_filter(self): self.assertMapEqual(test_execute("(filter (< :id 3) (6 5 4 3 2 1))"), [{ 'None': ldictify([2, 1]) }]) self.assertMapEqual( test_execute("(filter (inset :id (3, 1)) (6 5 4 3 2 1))"), [{ 'None': ldictify([3, 1]) }]) data = self.stringify_json([{ 'None': [{ "a": "foo1" }, { "a": "2foo" }, { "a": "bar" }] }]) self.assertMapEqual( test_execute("(filter (contains a foo) (json_literal %s))" % data), [{ 'None': [{ "a": "foo1" }, { "a": "2foo" }] }]) self.assertMapEqual( test_execute("(filter (prefix a foo) (json_literal %s))" % data), [{ 'None': [{ "a": "foo1" }] }]) self.assertMapEqual( test_execute("(filter (range :id (5 2)) (6 5 4 3 2 1))"), [{ 'None': ldictify([4, 3, 2]) }])
def test_difference(self): self.assertEqual( list(test_execute("(difference (6 5 4 3 2 1) (6 3 1))")), ldictify([2, 4, 5]))
def test_or(self): self.assertEqual(list(test_execute("(or (6 5 4 3 2 1) (10 6 3 1))")), ldictify([10, 6, 5, 4, 3, 2, 1]))
def test_and(self): self.assertEqual(list(test_execute("(and (6 5 4 3 2 1) (6 3 1))")), ldictify([6, 3, 1]))