Esempio n. 1
0
    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"))
Esempio n. 2
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"))
Esempio n. 3
0
    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))
Esempio n. 4
0
    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))
Esempio n. 5
0
    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"))
Esempio n. 6
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)
Esempio n. 7
0
    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)
Esempio n. 8
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)
Esempio n. 9
0
 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")
Esempio n. 10
0
 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")
Esempio n. 11
0
 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")
Esempio n. 12
0
    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"))
Esempio n. 13
0
 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")