Ejemplo n.º 1
0
    def testCustomTransformMoodel(self):
        def custom_transform(o):
            o.testattr=True
            return o
        fd=testmodels.get_a1_fullfetchdef()
        filter=testmodels.A1.name=='Full Graph'
        results=fetch(fd, filter=filter, transform=custom_transform)
        
        a1=results[0]
        self.assertTrue(a1.testattr, "testattr should be set to true by custom_transform")
        self.assertFalse(hasattr(a1,'id'), "id attribute has been set even though the custom transform was used.")

        # also test for models deeper in the graph
        self.assertTrue(a1.b1s[0].testattr, "testattr should be set to true by custom_transform")
        self.assertFalse(hasattr(a1.b1s[0],'id'), "id attribute has been set even though the custom transform was used.")

        self.assertTrue(a1.c1.testattr, "testattr should be set to true by custom_transform")
        self.assertFalse(hasattr(a1.c1,'id'), "id attribute has been set even though the custom transform was used.")

        self.assertTrue(a1.d1s[0].testattr, "testattr should be set to true by custom_transform")
        self.assertFalse(hasattr(a1.d1s[0],'id'), "id attribute has been set even though the custom transform was used.")
Ejemplo n.º 2
0
 def testFullGraphBasicImpl(self):
     from graphfetch import basic_graphfetch
     fd=testmodels.get_a1_fullfetchdef()
     filter=testmodels.A1.name=='Full Graph'
     results=fetch(fd, filter=filter, impl=basic_graphfetch.fetch_basic)
     self.assertFullGraphResults(results)
Ejemplo n.º 3
0
 def testFullGraph(self):
     fd=testmodels.get_a1_fullfetchdef()
     filter=testmodels.A1.name=='Full Graph'
     results=fetch(fd, filter=filter)
     self.assertFullGraphResults(results)