def testAdd(self): ''' Test the add ''' # Orbit class instance #print('Test Add ') otherStateVecs = TraitSeq() otherStateVecs.configure() cummStateVecs = TraitSeq() cummStateVecs.configure() for i in range(10): stateVec = createFacility() if (i < 5): self.stateVectors.append(stateVec) else: otherStateVecs.append(stateVec) cummStateVecs.append(stateVec) self.assertEqual(cummStateVecs, self.stateVectors + otherStateVecs) return
def testClear(self): ''' Test the clear ''' #print('Test clear ') otherStateVecs = TraitSeq() otherStateVecs.configure() for i in range(10): sv = createFacility() self.stateVectors.append(sv) otherStateVecs.append(sv) self.stateVectors.clear() otherStateVecs.clear() self.assertEqual(self.stateVectors, otherStateVecs) return
def testInsert(self): #print('Test Insert ') otherStateVecs = TraitSeq() otherStateVecs.configure() test = random.randint(0, 9) for i in range(10): sv = createFacility() self.stateVectors.append(sv) if test == i: svTest = sv else: otherStateVecs.append(sv) otherStateVecs.insert(test, svTest) self.stateVectors = self.process(self.stateVectors) otherStateVecs = self.process(otherStateVecs) self.assertEqual(self.stateVectors, otherStateVecs) return
def testReverse(self): ''' Test Reverse ''' #print('Test Reverse ') otherStateVecs = TraitSeq() otherStateVecs.configure() svList = [] for i in range(10): sv = createFacility() self.stateVectors.append(sv) svList.append(sv) for sv in svList[::-1]: otherStateVecs.append(sv) self.stateVectors.reverse() self.stateVectors = self.process(self.stateVectors) otherStateVecs = self.process(otherStateVecs) self.assertEqual(self.stateVectors, otherStateVecs) return
def testPop(self): ''' Test the Pop ''' #print('Test Pop ') otherStateVecs = TraitSeq() otherStateVecs.configure() for i in range(10): sv = createFacility() self.stateVectors.append(sv) otherStateVecs.append(sv) sv = createFacility() self.stateVectors.append(sv) # Pop self.stateVectors.pop() self.stateVectors = self.process(self.stateVectors) otherStateVecs = self.process(otherStateVecs) self.assertEqual(self.stateVectors, otherStateVecs) return
def testSet(self): ''' Test the Length ''' #print('Test Set ') skip = random.randint(0, 9) otherStateVecs = TraitSeq() otherStateVecs.configure() testsv = createFacility() for i in range(10): sv = createFacility() self.stateVectors.append(sv) if skip == i: otherStateVecs.append(testsv) else: otherStateVecs.append(sv) self.stateVectors[skip] = testsv self.stateVectors = self.process(self.stateVectors) otherStateVecs = self.process(otherStateVecs) self.assertEqual(self.stateVectors, otherStateVecs) return
def testDelete(self): ''' Test the delete ''' #print('Test delete ') otherStateVecs = TraitSeq() otherStateVecs.configure() skip = random.randint(0, 9) for i in range(10): sv = createFacility() if (i != skip): self.stateVectors.append(sv) otherStateVecs.append(sv) del otherStateVecs[skip] self.stateVectors = self.process(self.stateVectors) otherStateVecs = self.process(otherStateVecs) self.assertEqual(self.stateVectors, otherStateVecs) return
def testSort(self): ''' Test Sort ''' #print('Test Sort') import random otherStateVecs = TraitSeq() otherStateVecs.configure() svList = [] for i in range(10): sv = createFacility() svList.append(sv) otherStateVecs.append(sv) random.shuffle(svList) for sv in svList: self.stateVectors.append(sv) self.stateVectors.sort(key=lambda sv: sv.time) self.stateVectors = self.process(self.stateVectors) otherStateVecs = self.process(otherStateVecs) self.assertEqual(self.stateVectors, otherStateVecs) return
def setUp(self): self.stateVectors = TraitSeq() self.stateVectors.configure() pass