Esempio n. 1
0
 def test_can_add_atoms_to_structure(self):
     structure = AtomicStructure(self.atom1)
     self.assertEqual(structure._id_atoms, {500: {self.atom1}})
     self.assertEqual(structure._atoms, {self.atom1})
     structure.add_atom(self.atom2)
     self.assertEqual(structure._id_atoms, {500: {self.atom1, self.atom2}})
     self.assertEqual(structure._atoms, {self.atom1, self.atom2})
     structure.add_atom(self.atom3)
     self.assertEqual(structure._id_atoms, {
         500: {self.atom1, self.atom2},
         700: {self.atom3}
     })
     self.assertEqual(structure._atoms, set(self.atoms))
Esempio n. 2
0
 def test_can_update_atom_awareness(self):
     try:
         structure = AtomicStructure()
         structure.add_atom(self.atom1)
         self.assertFalse(hasattr(structure, "_atomicstructure"))
         AtomicStructure.__name__ = "Model"
         structure.add_atom(self.atom1)
         self.assertIs(self.atom1._model, structure)
         AtomicStructure.__name__ = "Molecule"
         structure.add_atom(self.atom1)
         self.assertIs(self.atom1._molecule, structure)
         AtomicStructure.__name__ = "Chain"
         structure.add_atom(self.atom1)
         self.assertIs(self.atom1._chain, structure)
         AtomicStructure.__name__ = "Model"
         structure.add_atom(self.atom1)
         self.assertIs(self.atom1._model, structure)
     finally:
         AtomicStructure.__name__ = "AtomicStructure"
Esempio n. 3
0
 def test_can_only_add_atoms(self):
     structure = AtomicStructure(self.atom1, self.atom2)
     with self.assertRaises(TypeError):
         structure.add_atom("atom")