def test_can_add_structure(self): structure = AtomStructure(self.atom1, self.atom2) other = Mock(AtomStructure) other._atoms = {self.atom3} structure.add(other) self.assertEqual(structure._id_atoms, { 500: {self.atom1, self.atom2}, 700: {self.atom3} }) self.assertEqual(structure._atoms, set(self.atoms))
def test_can_add_atom_to_structure(self): structure = AtomStructure(self.atom1) self.assertEqual(structure._id_atoms, {500: {self.atom1}}) self.assertEqual(structure._atoms, {self.atom1}) structure.add(self.atom2) self.assertEqual(structure._id_atoms, {500: {self.atom1, self.atom2}}) self.assertEqual(structure._atoms, {self.atom1, self.atom2}) structure.add(self.atom3) self.assertEqual(structure._id_atoms, { 500: {self.atom1, self.atom2}, 700: {self.atom3} }) self.assertEqual(structure._atoms, set(self.atoms))
def test_can_update_atom_awareness(self): try: AtomStructure.__name__ = "AtomStructure" structure = AtomStructure() structure.add(self.atom1) self.assertFalse(hasattr(self.atom1, "_atomstructure")) AtomStructure.__name__ = "Model" structure.add(self.atom1) self.assertIs(self.atom1._model, structure) AtomStructure.__name__ = "Ligand" structure.add(self.atom1) self.assertIs(self.atom1._ligand, structure) AtomStructure.__name__ = "Residue" structure.add(self.atom1) self.assertIs(self.atom1._residue, structure) AtomStructure.__name__ = "Chain" structure.add(self.atom1) self.assertIs(self.atom1._chain, structure) finally: AtomStructure.__name__ = "AtomStructure"