def test_touch(self): Cache.clean() self.assertDictEqual(Cache.get_objects(), {}) Cache.touch(self.__d, 'd') self.assertDictEqual(Cache.get('d'), self.__d) Cache.touch(None, 'd') self.assertDictEqual(Cache.get('d'), self.__d) Cache.touch({}, 'd') self.assertDictEqual(Cache.get('d'), self.__d)
def test_copy(self): Cache.clean() id = 'd' new_id = 'new_' + id Cache.add(self.__d, id) Cache.copy(id, new_id) self.assertDictEqual(Cache.get(new_id), self.__d)
def __build_smiles( side: Dict, logger: Logger = getLogger(__name__) ) -> str: """Build SMILES string from a stoichiometric chemical reaction side Parameters ---------- side: Dict Stoichiometric chemical reaction side logger: Logger, optional Returns ------- SMILES string """ return '.'.join([Cache.get(spe_id).get_smiles() for spe_id in side.keys()])
def test_get_wrong_id(self): Cache.clean() Cache.add(self.__d, 'd') self.assertEqual(Cache.get('d1'), None)
def test_remove_object_by_wrong_id(self): Cache.clean() Cache.add(self.__d, 'd') Cache.remove_object_by_id('d1') self.assertDictEqual(Cache.get('d'), self.__d)
def test_remove_object_by_id(self): Cache.clean() Cache.add(self.__d, 'd') Cache.remove_object_by_id('d') self.assertEqual(Cache.get('d'), None)
def test_rename_wrong_id(self): Cache.clean() Cache.add(self.__d, 'd') Cache.rename('d2', 'd1') self.assertEqual(Cache.get('d1'), None) self.assertDictEqual(Cache.get('d'), self.__d)
def test_add_wo_id(self): Cache.clean() Cache.add(self.__d) self.assertEqual(Cache.get('d'), None)
def test_add_with_id(self): Cache.clean() Cache.add(self.__d, 'd') self.assertDictEqual(Cache.get('d'), self.__d)