def test_message_expires(self): new = Message('abc') new.save('123') cache.clear() new = Message('abc') assert new.get() is None
def test_poll_failed(self): msg = Message('file-viewer:%s' % self.file_viewer) msg.save('I like cheese.') res = self.client.get(self.poll_url()) assert res.status_code == 200 data = json.loads(res.content) assert not data['status'] assert data['msg'] == ['I like cheese.']
def test_poll_failed(self): msg = Message('file-viewer:%s' % self.file_viewer) msg.save('I like cheese.') res = self.client.get(self.poll_url()) assert res.status_code == 200 data = json.loads(res.content) assert not data['status'] assert data['msg'] == ['I like cheese.']
def test_message_get_delete(self): new = Message('abc') new.save('123') new = Message('abc') assert new.get(delete=False) == '123' assert new.get(delete=True) == '123' assert new.get() is None
def compare_poll(request, diff): msgs = [] for f in (diff.left, diff.right): m = Message('file-viewer:%s' % f).get(delete=True) if m: msgs.append(m) return {'status': diff.is_extracted(), 'msg': msgs}
def test_message_expires(self): new = Message('abc') new.save('123') cache.clear() new = Message('abc') assert new.get() is None
def test_message_get_delete(self): new = Message('abc') new.save('123') new = Message('abc') assert new.get(delete=False) == '123' assert new.get(delete=True) == '123' assert new.get() is None
def extract_file(viewer, **kw): # This message is for end users so they'll see a nice error. msg = Message('file-viewer:%s' % viewer) msg.delete() task_log.debug('Unzipping %s for file viewer.' % viewer) try: lock_attained = viewer.extract() if not lock_attained: info_msg = ugettext( 'File viewer is locked, extraction for %s could be ' 'in progress. Please try again in approximately 5 minutes.' % viewer) msg.save(info_msg) except Exception, exc: error_msg = ugettext('There was an error accessing file %s.') % viewer if settings.DEBUG: msg.save(error_msg + ' ' + exc) else: msg.save(error_msg) task_log.error('Error unzipping: %s' % exc)
def extract_file(viewer, **kw): # This message is for end users so they'll see a nice error. msg = Message('file-viewer:%s' % viewer) msg.delete() task_log.debug('Unzipping %s for file viewer.' % viewer) try: lock_attained = viewer.extract() if not lock_attained: info_msg = ugettext( 'File viewer is locked, extraction for %s could be ' 'in progress. Please try again in approximately 5 minutes.' % viewer) msg.save(info_msg) except Exception, exc: error_msg = ugettext('There was an error accessing file %s.') % viewer if settings.DEBUG: msg.save(error_msg + ' ' + exc) else: msg.save(error_msg) task_log.error('Error unzipping: %s' % exc)
def poll(request, viewer): return { 'status': viewer.is_extracted(), 'msg': [Message('file-viewer:%s' % viewer).get(delete=True)] }
def test_message_save(self): new = Message('abc') new.save('123') new = Message('abc') assert new.get() == '123'
def test_message_save(self): new = Message('abc') new.save('123') new = Message('abc') assert new.get() == '123'