def commit(self, sn): """ The request referenced by the serial number has been completely processed and can be deleted from the journal. :param sn: A request serial number. :param sn: str """ try: path = self.journal[sn] unlink(path) log.debug('%s committed', sn) except KeyError: log.warn('%s not found for commit', sn)
def commit(self, sn): """ The request referenced by the serial number has been completely processed and can be deleted from the journal. :param sn: A request serial number. :param sn: str """ try: path = self.journal.pop(sn) unlink(path) log.debug('%s committed', sn) except KeyError: log.warning('%s not found for commit', sn)
def _read(path): """ Read a request. :param path: The path to the journal file. :type path: str :return: The read request. :rtype: Document """ with open(path) as fp: try: request = Document() body = fp.read() request.load(body) log.debug('read [%s]: %s', path, body) return request except ValueError: log.error('%s corrupt (discarded)', path) unlink(path)
def test_not_exist(self, _unlink): path = '/tmp/file' exception = OSError() exception.errno = errno.ENOENT _unlink.side_effect = exception unlink(path)
def test_unlink(self, _unlink): path = '/tmp/file' unlink(path) _unlink.assert_called_once_with(path)