Ejemplo n.º 1
0
 def testFailureFromFailure(self):
     failure = maybe_failure(ValueError("test"))
     failure2 = maybe_failure(failure)
     self.assertEqual(failure, failure2)
     self.assertEqual(failure.exc_info, failure2.exc_info)
     failure.logged = True
     self.assertRaises(ValueError, failure.throw)
Ejemplo n.º 2
0
 def testRemoteExcInfo(self):
     failure = maybe_failure(Exception("testRemoteExcInfo"))
     remote = pickle.loads(pickle.dumps(failure))
     # Now create a failure from the remote.exc_info
     failure2 = maybe_failure(remote.exc_info)
     self.assertEqual(failure2.exc_info, remote.exc_info)
     self.assertFalse(failure.logged)
     self.assertFalse(failure2.logged)
     mute_failure(self, failure)
     mute_failure(self, remote)
Ejemplo n.º 3
0
def task_form_info(request, form, result):
    '''Information regarding a Task run with links to the Task application
views.

:parameter request: A WSGI djpcms request class
:parameter form: A bound :class:`djpcms.forms.Form` used to run the task.
:parameter request: A WSGI djpcms request class
'''
    f = maybe_failure(result)
    if f is not None:
        return f
    elif isinstance(result, Task):
        id = result.id
    elif result and 'id' in result:
        id = result['id']
    else:
        form.add_error('Could not create task')
        return form
    rt = request.for_model(Task, urlargs={'id': id}, name='view')
    if rt:
        link = html.Widget('a', id, href=rt.url).render(rt)
    else:
        link = res['id']
    form.add_message(link + ' sent to task queue')
    return form
Ejemplo n.º 4
0
 def testLog(self):
     failure = maybe_failure(Exception("test"))
     error = failure.error
     log = mock.MagicMock(name="log")
     failure.log = log
     del failure
     gc.collect()
     log.assert_called_once_with()
Ejemplo n.º 5
0
def mute_failure(test, failure):
    #TODO: add test flag to control muting
    if not test.cfg.log_failures:
        maybe_failure(failure).mute()
Ejemplo n.º 6
0
 def test_errback(self):
     err = errback(ValueError)
     failure = maybe_failure(TypeError())
     self.assertEqual(err(failure), failure)
     failure.mute()
Ejemplo n.º 7
0
 def test_errback(self):
     err = errback(ValueError)
     failure = maybe_failure(TypeError())
     self.assertEqual(err(failure), failure)
     failure.mute()
Ejemplo n.º 8
0
 def testRemote(self):
     failure = maybe_failure(Exception("testRemote"))
     failure.logged = True
     remote = pickle.loads(pickle.dumps(failure))
     self.assertTrue(remote.logged)
Ejemplo n.º 9
0
 def test_repr(self):
     failure = maybe_failure(Exception("test_repr"))
     val = str(failure)
     self.assertEqual(repr(failure), val)
     self.assertTrue("Exception: test" in val)
     mute_failure(self, failure)