Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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()])
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
 def test_function(self):
     p = pymag.Pipeline()
     p.append(pymag.match())
     p.append(pymag.addFields({"dummy": pymag.func}))