def test_ordered_polymer_species_manipulations(self): a = Species("A") b = Species("B").set_dir("forward") c = Species("C").set_dir("reverse") truth = OrderedPolymerSpecies([Species("A"),[Species("B"),"forward"],\ Species("C").set_dir("reverse")],attributes=["ooga"]) reversd = OrderedPolymerSpecies([Species("C").set_dir("forward"),[Species("B"),"reverse"],\ Species("A")],attributes=["ooga"]) unreplaced = OrderedPolymerSpecies([Species("z"),[Species("B"),"forward"],\ Species("C").set_dir("reverse")],attributes=["ooga"]) uninserted = OrderedPolymerSpecies([Species("A"),\ Species("C").set_dir("reverse")],attributes=["ooga"]) unappended = OrderedPolymerSpecies([Species("A"),[Species("B"),"forward"],\ ],attributes=["ooga"]) #replace unreplaced.replace(0,a) self.assertEqual(unreplaced,truth) #insert uninserted.insert(1,b) self.assertEqual(uninserted,truth) #append unappended.append(c) self.assertEqual(unappended,truth) #reverse reversd.reverse() self.assertEqual(reversd,truth)
def test_ordered_polymer_species_initialization(self): a = Species("A") x = OrderedPolymerSpecies([Species("A"),[Species("B"),"forward"],\ Species("C").set_dir("reverse")],attributes=["ooga"]) #repr revtest = OrderedPolymerSpecies([Species("A",direction="forward"),Species("A")]) r1 = str(revtest) revtest.reverse() r2 = str(revtest) self.assertEqual(type(r1),str) self.assertNotEqual(r1,r2) #pretty_print self.assertEqual(type(x.pretty_print()),str) #make sure we're copying self.assertEqual(a.parent,None) #make sure we're setting the properties of the components self.assertEqual(x[0].parent,x) self.assertEqual(x[1].parent,x) self.assertEqual(x[2].parent,x) self.assertEqual(x[1].direction,"forward") self.assertEqual(x[2].direction,"reverse") self.assertEqual(x[0].position,0) self.assertEqual(x[1].position,1) self.assertEqual(x[2].position,2) #circularity x.circular = True self.assertEqual(x.circular, True) self.assertIn("circular",x.attributes) x.circular = False self.assertEqual(x.circular, False) self.assertNotIn("circular",x.attributes)