def test_atom_can_get_atom_by_id(self, mock_atoms): mock_atoms.return_value = {self.atoms[1]} structure = AtomStructure(self.atom1, self.atom2, self.atom3) atom = structure.atom(id=700) self.assertFalse(mock_atoms.called) self.assertIs(atom, self.atom3) atom = structure.atom(500) self.assertFalse(mock_atoms.called) self.assertIn(atom, (self.atom1, self.atom2)) self.assertIsNone(structure.atom(id=100))
def test_atom_can_return_none(self, mock_atoms): structure = AtomStructure(self.atom1, self.atom2, self.atom3) mock_atoms.return_value = set() self.assertIs(structure.atom(element="C"), None)
def test_atom_calls_atoms(self, mock_atoms): mock_atoms.return_value = {self.atoms[0]} structure = AtomStructure(self.atom1, self.atom2, self.atom3) atom = structure.atom(fufu=500, element="A") mock_atoms.assert_called_with(fufu=500, element="A") self.assertIs(atom, self.atom1)