def Test_DAGStructure_VertexEdgeSetQueries(self): #multiple users so we can test this feature u1 = MyUser(user="******", key_name="Bill") u1.put() u2 = MyUser(user="******", key_name="Ted") u2.put() #first insert all known tags t1 = TagVertex(u1, "Tag1") t1.ttlCount = 1 t1.put() t2 = TagVertex(u1, "Tag2") t2.ttlCount = 2 t2.put() t3 = TagVertex(u1, "Tag3") t3.ttlCount = 3 t3.put() t4 = TagVertex(u1, "Tag4") t4.ttlCount = 4 t4.put() t5 = TagVertex(u1, "Tag5") t5.ttlCount = 5 t5.put() t6 = TagVertex(u1, "Tag6") t6.ttlCount = 6 t6.put() t1.AddEdge(t2, 11) t1.AddEdge(t3, 12) t2.AddEdge(t3, 13) t2.AddEdge(t4, 14) t2.AddEdge(t6, 15) t3.AddEdge(t4, 16) #some duplicate tags for the second user #(just noise - the calls here work from vertex references #and so should never see these 'other' tags t22 = TagVertex(u2, "Tag2") t22.ttlCount = 22 t22.put() t33 = TagVertex(u2, "Tag3") t33.ttlCount = 33 t33.put() t44 = TagVertex(u2, "Tag4") t44.ttlCount = 44 t44.put() t22.AddEdge(t33, 13) t22.AddEdge(t44, 14) t33.AddEdge(t44, 16) # test getting the set of outgoing edges myEdges = t2.GetMyEdges() check.ok_(myEdges != None) check.ok_(len(myEdges) == 3) check.ok_(myEdges.has_key("Tag3")) check.ok_(myEdges.has_key("Tag4")) check.ok_(myEdges.has_key("Tag6")) check.ok_(myEdges["Tag3"].edgeCount == 13) check.ok_(myEdges["Tag4"].edgeCount == 14) check.ok_(myEdges["Tag6"].edgeCount == 15) #get the set of connected vertices recorded in a vertex myConectees = t3.GetMyAdjacentVertices() check.ok_(myConectees != None) check.ok_(len(myConectees) == 1) check.ok_(myConectees.has_key("Tag4")) #test getting the set of incoming edges otherConectees = t3.GetAdjacentVerticesRecordedElsewhere() check.ok_(otherConectees != None) check.ok_(len(otherConectees) == 2) check.ok_(otherConectees.has_key("Tag1")) check.ok_(otherConectees.has_key("Tag2")) #get the total set of connected vertices connectees = t3.GetAllAdjacentVertices() check.ok_(connectees != None) check.ok_(len(connectees) == 3) check.ok_(connectees.has_key("Tag1")) check.ok_(connectees.has_key("Tag2")) check.ok_(connectees.has_key("Tag4"))