def test_finishJobNull(self): self.gw.functions['blah'] = lambda x: None job = client._GearmanJob("test\0blah\0junk") d = self.gw._finishJob(job) d.addCallback( lambda x: self.assertReceived(constants.WORK_COMPLETE, "test\0"))
def test_finishJob(self): self.gw.functions['blah'] = lambda x: x.data.upper() job = client._GearmanJob(handle="test", function="blah", data="junk") d = self.gw._finishJob(job) d.addCallback(lambda x: self.assertReceived(constants.WORK_COMPLETE, "test\0JUNK"))
def test_constructor(self): gj = client._GearmanJob(handle="footdle", function="dys", data="some data") self.assertEquals("footdle", gj.handle) self.assertEquals("dys", gj.function) self.assertEquals("some data", gj.data) self.assertEquals("<GearmanJob footdle func=dys with 9 bytes of data>", repr(gj))
def test_constructor(self): gj = client._GearmanJob("footdle\0dys\0some data") self.assertEquals("footdle", gj.handle) self.assertEquals("dys", gj.function) self.assertEquals("some data", gj.data) self.assertEquals("<GearmanJob footdle func=dys with 9 bytes of data>", repr(gj))
def test_finishJobNull(self): self.gw.functions['blah'] = lambda x: None job = client._GearmanJob("test\0blah\0junk") d = self.gw._finishJob(job) d.addCallback(lambda x: self.assertReceived(constants.WORK_COMPLETE, "test\0"))
def test_finishJobException(self): def _failing(x): raise Exception("failed") self.gw.functions['blah'] = _failing job = client._GearmanJob("test\0blah\0junk") d = self.gw._finishJob(job) def _checkReceived(x): self.assertReceived(constants.WORK_EXCEPTION, "test\0" + 'Exception(failed)') self.assertReceived(constants.WORK_FAIL, "test\0") d.addCallback(_checkReceived)
def test_finishJobException(self): def _failing(x): raise Exception("failed") self.gw.functions["blah"] = _failing job = client._GearmanJob(handle="test", function="blah", data="junk") d = self.gw._finishJob(job) def _checkReceived(x): self.assertReceived(constants.WORK_EXCEPTION, "test\0" + "Exception(failed)") self.assertReceived(constants.WORK_FAIL, "test") d.addCallback(_checkReceived)
def test_sendingJobResponse(self): job = client._GearmanJob("test\0blah\0junk") self.gw._send_job_res(constants.WORK_COMPLETE, job, "the value") self.assertReceived(constants.WORK_COMPLETE, "test\0the value")
def test_sendingJobResponse(self): job = client._GearmanJob(handle="test", function="blah", data="junk") self.gw._send_job_res(constants.WORK_COMPLETE, job, "the value") self.assertReceived(constants.WORK_COMPLETE, "test\0the value")
def test_finishJobNull(self): self.gw.functions["blah"] = lambda x: None job = client._GearmanJob(handle="test", function="blah", data="junk") d = self.gw._finishJob(job) d.addCallback(lambda x: self.assertReceived(constants.WORK_COMPLETE, "test\0"))