def test_match(self): x = pymag.Pipeline() self.assertEqual(len(x), 0) m = pymag.match() x = pymag.Pipeline([pymag.match()]) self.assertEqual(len(x), 1)
def test_pipeline_init(self): x = pymag.Pipeline() self.assertEqual(len(x), 0) x = pymag.Pipeline([pymag.match()]) self.assertEqual(len(x), 1) self.assertRaises(ValueError, pymag.Pipeline, [1]) self.assertRaises(ValueError, pymag.Pipeline, [pymag.out("outy"), pymag.match()])
def test_limit(self): p = pymag.Pipeline() limiter = pymag.limit(10) p.append(limiter) print(p) c = p.aggregate(self.col) for d in c: print(d)
def test_function(self): p = pymag.Pipeline() func = pymag.function(pymag.JSCode(add_a_string, "bongo")) print("func") pprint.pprint(func()) limiter = pymag.limit(10) adder = pymag.addFields({"new_field": func()}) p.append(limiter) p.append(adder) pprint.pprint(p) c = p.aggregate(self.col) for d in c: print(d)
def test_function(self): p = pymag.Pipeline() p.append(pymag.match()) p.append(pymag.addFields({"dummy": pymag.func}))