Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
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()])
Пример #4
0
 def test_get_wrong_id(self):
     Cache.clean()
     Cache.add(self.__d, 'd')
     self.assertEqual(Cache.get('d1'), None)
Пример #5
0
 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)
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 def test_add_wo_id(self):
     Cache.clean()
     Cache.add(self.__d)
     self.assertEqual(Cache.get('d'), None)
Пример #9
0
 def test_add_with_id(self):
     Cache.clean()
     Cache.add(self.__d, 'd')
     self.assertDictEqual(Cache.get('d'), self.__d)