Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(586)  |  Call(586)  |  Derive(0)  |  Import(0)

src/q/l/qless-core-HEAD/test/test_locks.py   qless-core(Download)
    def setUp(self):
        TestQless.setUp(self)
        # No grace period for any of these tests
        self.lua('config.set', 0, 'grace-period', 0)
 
    def test_move(self):
        '''Moving ajob should expire any existing locks'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        self.lua('pop', 1, 'queue', 'worker', 10)
        self.lua('heartbeat', 2, 'jid', 'worker', {})
        self.lua('heartbeat', 2, 'jid', 'worker', {})
        # Move the job after it's been popped
        self.lua('put', 3, 'worker', 'other', 'jid', 'klass', {}, 0)
        # Now this job cannot be heartbeated
        self.assertRaisesRegexp(redis.ResponseError, r'waiting',

src/q/l/qless-core-HEAD/test/test_recurring.py   qless-core(Download)
 
        # In order for these tests to work, there must be a job
        self.lua('recur', 0, 'queue', 'jid', 'klass', {}, 'interval', 60, 0)
        self.assertMalformed(self.lua, [
            ('recur.update', 0, 'jid', 'priority'),
    def test_basic(self):
        '''Simple recurring jobs'''
        self.lua('recur', 0, 'queue', 'jid', 'klass', {}, 'interval', 60, 0)
        # Pop off the first recurring job
        popped = self.lua('pop', 0, 'queue', 'worker', 10)
        self.assertEqual(len(popped), 1)
        self.assertEqual(popped[0]['jid'], 'jid-1')
 
        # If we wait 59 seconds, there won't be a job, but at 60, yes
        popped = self.lua('pop', 59, 'queue', 'worker', 10)
        popped = self.lua('pop', 59, 'queue', 'worker', 10)
        self.assertEqual(len(popped), 0)
        popped = self.lua('pop', 61, 'queue', 'worker', 10)
        self.assertEqual(len(popped), 1)
        self.assertEqual(popped[0]['jid'], 'jid-2')

src/q/l/qless-core-HEAD/test/test_dependencies.py   qless-core(Download)
    def test_unlock(self):
        '''Dependencies unlock their dependents upon completion'''
        self.lua('put', 0, 'worker', 'queue', 'a', 'klass', {}, 0)
        self.lua('put', 0, 'worker', 'queue', 'b', 'klass', {}, 0, 'depends', ['a'])
        # Only 'a' should show up
        self.assertEqual(len(self.lua('pop', 1, 'queue', 'worker', 10)), 1)
        self.lua('complete', 2, 'a', 'worker', 'queue', {})
    def test_unlock_with_delay(self):
        '''Dependencies schedule their dependents upon completion'''
        self.lua('put', 0, 'worker', 'queue', 'a', 'klass', {}, 0)
        self.lua('put', 0, 'worker', 'queue', 'b', 'klass', {}, 1000, 'depends', ['a'])
        # Only 'a' should show up

src/q/l/qless-core-HEAD/test/test_job.py   qless-core(Download)
    def test_log(self):
        '''Can add a log to a job'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        self.lua('log', 0, 'jid', 'foo', {'foo': 'bar'})
        self.assertEqual(self.lua('get', 0, 'jid')['history'], [
    def test_history(self):
        '''We only keep the most recent max-job-history items in history'''
        self.lua('config.set', 0, 'max-job-history', 5)
        for index in range(100):
            self.lua('put', index, 'worker', 'queue', 'jid', 'klass', {}, 0)
    def test_complete_waiting(self):
        '''Only popped jobs can be completed'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        self.assertRaisesRegexp(redis.ResponseError, r'waiting',
            self.lua, 'complete', 1, 'jid', 'worker', 'queue', {})

src/q/l/qless-core-HEAD/test/test_queue.py   qless-core(Download)
    def test_complete(self):
        '''Verify we can list complete jobs'''
        jids = map(str, range(10))
        for jid in jids:
            self.lua('put', jid, 'worker', 'queue', jid, 'klass', {}, 0)
            self.lua('pop', jid, 'queue', 'worker', 10)
            self.lua('complete', jid, jid, 'worker', 'queue', {})
            complete = self.lua('jobs', jid, 'complete')
    def test_running(self):
        '''Verify that we can get a list of running jobs in a queue'''
        jids = map(str, range(10))
        for jid in jids:
            self.lua('put', jid, 'worker', 'queue', jid, 'klass', {}, 0)

src/q/l/qless-core-HEAD/test/test_fail.py   qless-core(Download)
    def test_basic(self):
        '''Fail a job in a very basic way'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        self.lua('pop', 1, 'queue', 'worker', 10)
        self.lua('fail', 2, 'jid', 'worker', 'group', 'message', {})
    def test_put(self):
        '''Can put a job that has been failed'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        self.lua('pop', 1, 'queue', 'worker', 10)
        self.lua('fail', 2, 'jid', 'worker', 'group', 'message', {})

src/q/l/qless-core-HEAD/test/test_stats.py   qless-core(Download)
    def test_wait(self):
        '''It correctly tracks wait times'''
        stats = self.lua('stats', 0, 'queue', 0)
        self.assertEqual(stats['wait']['count'], 0)
        self.assertEqual(stats['run']['count'], 0)
        jids = map(str, range(20))
        for jid in jids:
            self.lua('put', 0, 'worker', 'queue', jid, 'klass', {}, 0)
        for jid in jids:
            self.lua('pop', jid, 'queue', 'worker', 1)
 
        stats = self.lua('stats', 0, 'queue', 0)
        jids = map(str, range(20))
        for jid in jids:
            self.lua('put', 0, 'worker', 'queue', jid, 'klass', {}, 0)
            self.lua('pop', 0, 'queue', 'worker', 1)
        for jid in jids:

src/q/l/qless-core-HEAD/test/test_tag.py   qless-core(Download)
    def test_add(self):
        '''Add a tag'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        self.lua('tag', 0, 'add', 'jid', 'foo')
        self.assertEqual(self.lua('get', 0, 'jid')['tags'], ['foo'])
 
    def test_remove(self):
        '''Remove a tag'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0, 'tags', ['foo'])
        self.lua('tag', 0, 'remove', 'jid', 'foo')
    def test_add_existing(self):
        '''We shouldn't double-add tags that already exist for the job'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0, 'tags', ['foo'])
        self.lua('tag', 0, 'add', 'jid', 'foo')
        self.assertEqual(self.lua('get', 0, 'jid')['tags'], ['foo'])

src/q/l/qless-core-HEAD/test/test_worker.py   qless-core(Download)
    def setUp(self):
        TestQless.setUp(self)
        # No grace period
        self.lua('config.set', 0, 'grace-period', 0)
 
    def test_basic(self):
        '''Basic worker-level information'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        self.lua('pop', 1, 'queue', 'worker', 10)
    def test_stalled(self):
        '''We should be able to detect stalled jobs'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        job = self.lua('pop', 1, 'queue', 'worker', 10)[0]
        expires = job['expires'] + 10

src/q/l/qless-core-HEAD/test/test_events.py   qless-core(Download)
    def test_track(self):
        '''We should hear chatter about tracking and untracking jobs'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        with self.lua:
            self.lua('track', 0, 'track', 'jid')
 
        with self.lua:
            self.lua('track', 0, 'untrack', 'jid')
        self.assertEqual(self.lua.log, [{
            'channel': 'ql:untrack',
    def test_track_canceled(self):
        '''Canceling a tracked job should spawn some data'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        self.lua('track', 0, 'track', 'jid')
        with self.lua:

  1 | 2  Next