def testShowDistributors(self): self.zones.createZone(1) self.zones.createZone(2) c = DSMember(123956, 'Cicueto', 'Colombia', True) d = DSMember(123957, 'Zarina', 'Zuzumba', True) self.zones.assignsDistributor(c, 1) self.zones.assignsDistributor(d, 1) s = self.zones.showDistributors(1) assert s == "Cicueto Colombia, Zarina Zuzumba"
def testDeleteZone(self): self.zones.createZone(1) self.zones.createZone(2) self.zones.createZone(3) c = DSMember(123956, 'Cicueto', 'Colombia', True) d = DSMember(123957, 'Zarina', 'Zuzumba', True) self.zones.assignsDistributor(c, 2) self.zones.assignsDistributor(d, 2) self.zones.deleteZone(2) a = self.zones.root.members.size b = self.zones.root.leftChild.members.size assert a == 1 and b == 1 and self.zones.find(2) == None
def testAssignDistributor(self): self.zones.createZone(1) c = DSMember(123956, 'Cicueto', 'Colombia', True) a = self.zones.root.members.isEmpty() self.zones.assignsDistributor(c, 1) b = self.zones.root.members.isEmpty() assert a == True and b == False
def testShowZones(self): self.zones.createZone(1) self.zones.createZone(2) c = DSMember(123956, 'Cicueto', 'Colombia', True) self.zones.assignsDistributor(c, 1) s = self.zones.showZones() assert s == "Zone 1: Cicueto Colombia. Zone 2: . "
def addMember(self, iD, name, lastname, status): member = DSMember(iD, name, lastname, status) if self.__size == 0: self.addFirst(member) else: nodelt = self.__head index = 0 while nodelt != None: if nodelt.element.lastname > member.lastname: return self.insertAt(index, member) else: index += 1 nodelt = nodelt.next return self.addLast(member)
def addMember(self,iD, name, lastname, status): member = DSMember(iD, name, lastname, status) # T(n) = 1 + 14 = 15 if self.size == 0: self.addFirst(member) # T(n) = 9 else: nodelt = self.head index = 0 while nodelt != None: if nodelt.element.lastname > member.lastname: return self.insertAt(index, member) # T(n) = 1 + (4n + 11) = 4n + 12 else: index +=1 nodelt = nodelt.next return self.addLast(member) # T(n) = 1 + 10 = 11
def testAssignDistributor(self): self.zones.createZone(1) c = DSMember(123956, 'Cicueto', 'Colombia', True) a = self.zones.root.members.isEmpty() self.zones.assignsDistributor(c, 1) b = self.zones.root.members.isEmpty() assert a == True and b == False def testDeleteDistributor(self): self.zones.createZone(1) c = DSMember(123956, 'Cicueto', 'Colombia', True) self.zones.assignsDistributor(c, 1) a = self.zones.root.members.isEmpty() self.zones.deleteDistributor(c, 1) b = self.zones.root.members.isEmpty() assert a == False and b == True a = Zones() a.createZone(1) a.createZone(2) a.insert(3) c = DSMember(123956, 'Cicueto', 'Colombia', True) d = DSMember(123957, 'Zarina', 'Zuzumba', True) a.assignsDistributor(c, 1) a.assignsDistributor(d, 1) b = a.showDistributors(1) print(b) if __name__ == '__main__': unittest.main()