Beispiel #1
0
    def test_fail(self):
        class TestException(Exception):
            pass

        def handler(job, data):
            raise TestException("someone set us up the bomb")

        # Set up the arbeiter to read data from the "in" queue
        job = Job(["localhost:22133"], "in", handler)

        # Flush all values out of it's work queue
        job.flush()

        # Push a value into the "in" queue
        job.push("Test")

        # Tell the arbeiter to handle the next item in it's queue
        self.assertRaises(TestException, job.handle_one)

        # Ensure the data was put back in the queue
        self.assertEqual(job.peek("in"), "Test")
Beispiel #2
0
    def test_sink(self):
        results = []

        def handler(job, data):
            data = data.lower()
            results.append(data)

        # Set up the arbeiter to read data from the "in" queue
        job = Job(["localhost:22133"], "in", handler)

        # Flush all values out of it's work queue
        job.flush()

        # Push a value into the "in" queue
        job.push("Test")

        # Tell the arbeiter to handle the next item in it's queue
        job.handle_one()

        # Assert that everything worked
        self.assertEqual(results[0], "test")

        # Ensure the data has been removed from the queue
        self.assertTrue(job.peek("in") is None)