def test_FM_add_remove(self): """ test FM add() and remove() """ fm = admit.Flow() # connection map diagram: a0->a1->a2->a3 # structure of an element of the triple-nested dictionary of connmap: # src_taskid: {des_taskid: {des_bdpport: (si,sp, di,dp)}} self.correct_connmap = {0: {1: {0: (0, 0, 1, 0)}}, 1: {2: {0: (1, 0, 2, 0)}}, 2: {3: {0: (2, 0, 3, 0)}}} tasklist= list() for i in range(0,4): a = AT() a._baseDir = admit.Project.baseDir # Each AT needs an output BDP b = File_BDP(); b.type="TEST_BDP%d" % i a._bdp_out.append( b ) tasklist.append( a ) if i == 0: taskid = fm.add( tasklist[i] ) else: taskid = fm.add( tasklist[i], [(tasklist[i-1]._taskid,0)]) self.assertEqual(fm._connmap, self.correct_connmap) # Remove a2 and its downstream from a0->a1->a2->a3 # The result diagram is a0->a1 self.correct_connmap = {0: {1: {0: (0, 0, 1, 0)}}} fm.remove(2) self.assertEqual(fm._connmap, self.correct_connmap)
def test_flow(self): # Test insertion of tasks (FM method: add(at, stuples, dtuples)) if (self.verbose) : print "\n------- Test Insertion ------------" # connection map diagram: a0->a1->a2->a3 # structure of an element of the triple-nested dictionary of connmap: # src_taskid: {des_taskid: {des_bdpport: (si,sp, di,dp)}} self.correct_connmap = {0: {1: {0: (0, 0, 1, 0)}}, 1: {2: {0: (1, 0, 2, 0)}}, 2: {3: {0: (2, 0, 3, 0)}}} for i in range(0,4): name = "TEST_AT%d" % i; if (self.verbose) : print "inserting task %s " % name a = AT() a._baseDir = admit.Project.baseDir # Each AT needs an output BDP b = BDP(); b.type="TEST_BDP%d" % i a._bdp_out.append( b ) self.task.append( a ) if i == 0: taskid = self.fm.add( self.task[i] ) else: taskid = self.fm.add( self.task[i], [(self.task[i-1]._taskid,0)]) if (self.verbose) : self.fm.show() self.assertEqual(self.fm._connmap, self.correct_connmap) if (self.verbose) : print "-------- End of Test Insertion ------------" # Print the 4-tuples of the connection map if (self.verbose) : print "\n------- Print Connection Map ------------" cm = self.fm._connmap if (self.verbose) : print cm for si in cm.keys(): for di in cm[si].keys(): for dp in cm[si][di].keys(): if (self.verbose) : print cm[si][di][dp] if (self.verbose) : print "-------- End of Print ConnMap ------------" # Remove a2 and its downstream from a0->a1->a2->a3 # The result diagram is a0->a1 if (self.verbose) : print "\n------- Test Remove ------------" self.correct_connmap = {0: {1: {0: (0, 0, 1, 0)}}} self.fm.remove(2) if (self.verbose): self.fm.show() self.assertEqual(self.fm._connmap, self.correct_connmap) if (self.verbose) : print "-------- End of Test Remove ------------"
def test_FM_add_remove(self): """ test FM add() and remove() """ fm = admit.Flow() # connection map diagram: a0->a1->a2->a3 # structure of an element of the triple-nested dictionary of connmap: # src_taskid: {des_taskid: {des_bdpport: (si,sp, di,dp)}} self.correct_connmap = { 0: { 1: { 0: (0, 0, 1, 0) } }, 1: { 2: { 0: (1, 0, 2, 0) } }, 2: { 3: { 0: (2, 0, 3, 0) } } } tasklist = list() for i in range(0, 4): a = AT() a._baseDir = admit.Project.baseDir # Each AT needs an output BDP b = File_BDP() b.type = "TEST_BDP%d" % i a._bdp_out.append(b) tasklist.append(a) if i == 0: taskid = fm.add(tasklist[i]) else: taskid = fm.add(tasklist[i], [(tasklist[i - 1]._taskid, 0)]) self.assertEqual(fm._connmap, self.correct_connmap) # Remove a2 and its downstream from a0->a1->a2->a3 # The result diagram is a0->a1 self.correct_connmap = {0: {1: {0: (0, 0, 1, 0)}}} fm.remove(2) self.assertEqual(fm._connmap, self.correct_connmap)
def test_flow(self): # Test insertion of tasks (FM method: add(at, stuples, dtuples)) if (self.verbose): print "\n------- Test Insertion ------------" # connection map diagram: a0->a1->a2->a3 # structure of an element of the triple-nested dictionary of connmap: # src_taskid: {des_taskid: {des_bdpport: (si,sp, di,dp)}} self.correct_connmap = { 0: { 1: { 0: (0, 0, 1, 0) } }, 1: { 2: { 0: (1, 0, 2, 0) } }, 2: { 3: { 0: (2, 0, 3, 0) } } } for i in range(0, 4): name = "TEST_AT%d" % i if (self.verbose): print "inserting task %s " % name a = AT() a._baseDir = admit.Project.baseDir # Each AT needs an output BDP b = BDP() b.type = "TEST_BDP%d" % i a._bdp_out.append(b) self.task.append(a) if i == 0: taskid = self.fm.add(self.task[i]) else: taskid = self.fm.add(self.task[i], [(self.task[i - 1]._taskid, 0)]) if (self.verbose): self.fm.show() self.assertEqual(self.fm._connmap, self.correct_connmap) if (self.verbose): print "-------- End of Test Insertion ------------" # Print the 4-tuples of the connection map if (self.verbose): print "\n------- Print Connection Map ------------" cm = self.fm._connmap if (self.verbose): print cm for si in cm.keys(): for di in cm[si].keys(): for dp in cm[si][di].keys(): if (self.verbose): print cm[si][di][dp] if (self.verbose): print "-------- End of Print ConnMap ------------" # Remove a2 and its downstream from a0->a1->a2->a3 # The result diagram is a0->a1 if (self.verbose): print "\n------- Test Remove ------------" self.correct_connmap = {0: {1: {0: (0, 0, 1, 0)}}} self.fm.remove(2) if (self.verbose): self.fm.show() self.assertEqual(self.fm._connmap, self.correct_connmap) if (self.verbose): print "-------- End of Test Remove ------------"