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

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

src/q/l/qless-core-HEAD/test/test_queue.py   qless-core(Download)
            self.lua('complete', jid, jid, 'worker', 'queue', {})
            complete = self.lua('jobs', jid, 'complete')
            self.assertEqual(len(complete), int(jid) + 1)
            self.assertEqual(complete[0], jid)
 
            self.lua('pop', jid, 'queue', 'worker', 10)
            running = self.lua('jobs', jid, 'running', 'queue')
            self.assertEqual(len(running), int(jid) + 1)
            self.assertEqual(running[-1], jid)
 
            self.lua('pop', jid, 'queue', 'worker', 10)
            stalled = self.lua('jobs', int(jid) + 20, 'stalled', 'queue')
            self.assertEqual(len(stalled), int(jid) + 1)
            self.assertEqual(stalled[-1], jid)
 

src/q/l/qless-core-HEAD/test/test_locks.py   qless-core(Download)
        job = self.lua('pop', 1, 'queue', 'worker', 10)[0]
        # No jobs should be available since the lock is still valid
        self.assertEqual(self.lua('pop', 2, 'queue', 'worker', 10), {})
        self.assertEqual(self.lua(
            'pop', job['expires'] + 10, 'queue', 'another', 10), [{
        job = self.lua('pop', 1, 'queue', 'worker', 10)[0]
        # No jobs should be available since the lock is still valid
        self.assertEqual(self.lua('pop', 2, 'queue', 'worker', 10), {})
        # We should see our expiration update after a heartbeat
        self.assertTrue(
        self.lua('pop', 0, 'queue', 'worker', 10)
        job = self.lua('pop', 0, 'queue', 'another', 10)[0]
        self.assertEqual(job['retries'], 5)
        self.assertEqual(job['remaining'], 4)
 

src/q/l/qless-core-HEAD/test/test_dependencies.py   qless-core(Download)
        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', {})
        # And now 'b' should be available
        self.assertEqual(
            self.lua('pop', 3, 'queue', 'worker', 10)[0]['jid'], 'b')
        self.lua('put', 0, 'worker', 'queue', 'b', 'klass', {}, 1000, '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', {})
        # And now 'b' should be scheduled
        self.assertEqual(self.lua('get', 3, 'b')['state'], 'scheduled')
        # After we wait for the delay, it should be available
        self.assertEqual(len(self.lua('peek', 1000, 'queue', 10)), 1)

src/q/l/qless-core-HEAD/test/test_recurring.py   qless-core(Download)
        # 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)
        self.assertEqual(len(popped), 0)
        popped = self.lua('pop', 61, 'queue', 'worker', 10)
        self.assertEqual(len(popped), 1)
        popped = self.lua('pop', 61, 'queue', 'worker', 10)
        self.assertEqual(len(popped), 1)
        self.assertEqual(popped[0]['jid'], 'jid-2')
 
    def test_offset(self):

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)
 
        stats = self.lua('stats', 0, 'queue', 0)
        self.assertEqual(stats['wait']['count'], 20)
        self.assertAlmostEqual(stats['wait']['mean'], 9.5)
        self.assertAlmostEqual(stats['wait']['std'], 5.916079783099)
        self.assertEqual(stats['wait']['histogram'][0:20], [1] * 20)
        self.assertEqual(sum(stats['wait']['histogram']), 20)

src/q/l/qless-py-0.10.1/test/test_job.py   qless-py(Download)
            'dependents', 'dependencies']
        values = [getattr(job, att) for att in atts]
        self.assertEqual(dict(zip(atts, values)), {
            'data': {'whiz': 'bang'},
            'dependencies': [],
    def test_set_priority(self):
        '''We can set a job's priority'''
        self.client.queues['foo'].put('Foo', {}, jid='jid', priority=0)
        self.assertEqual(self.client.jobs['jid'].priority, 0)
        self.client.jobs['jid'].priority = 10
        self.assertEqual(self.client.jobs['jid'].priority, 10)
    def test_queue(self):
        '''Exposes a queue object'''
        self.client.queues['foo'].put('Foo', {}, jid='jid')
        self.assertEqual(self.client.jobs['jid'].queue.name, 'foo')
 
    def test_klass(self):
        '''Exposes the class for a job'''
        self.client.queues['foo'].put(Job, {}, jid='jid')
        self.assertEqual(self.client.jobs['jid'].klass, Job)

src/q/l/qless-py-HEAD/test/test_job.py   qless-py(Download)
            'dependents', 'dependencies']
        values = [getattr(job, att) for att in atts]
        self.assertEqual(dict(zip(atts, values)), {
            'data': {'whiz': 'bang'},
            'dependencies': [],
    def test_set_priority(self):
        '''We can set a job's priority'''
        self.client.queues['foo'].put('Foo', {}, jid='jid', priority=0)
        self.assertEqual(self.client.jobs['jid'].priority, 0)
        self.client.jobs['jid'].priority = 10
        self.assertEqual(self.client.jobs['jid'].priority, 10)
    def test_queue(self):
        '''Exposes a queue object'''
        self.client.queues['foo'].put('Foo', {}, jid='jid')
        self.assertEqual(self.client.jobs['jid'].queue.name, 'foo')
 
    def test_klass(self):
        '''Exposes the class for a job'''
        self.client.queues['foo'].put(Job, {}, jid='jid')
        self.assertEqual(self.client.jobs['jid'].klass, Job)

src/q/l/qless-core-HEAD/test/test_worker.py   qless-core(Download)
    def test_basic(self):
        '''Basic worker-level information'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        self.lua('pop', 1, 'queue', 'worker', 10)
        self.assertEqual(self.lua('workers', 2, 'worker'), {
            'jobs': ['jid'],
            'stalled': {}
        })
        self.assertEqual(self.lua('workers', 2), [{
        expires = job['expires'] + 10
        self.lua('peek', expires, 'queue', 10)
        self.assertEqual(self.lua('workers', expires, 'worker'), {
            'jobs': {},
            'stalled': ['jid']
        })
        self.assertEqual(self.lua('workers', expires), [{
    def test_locks(self):
        '''When a lock is lost, removes the job from the worker's info'''
        self.lua('put', 0, 'worker', 'queue', 'jid', 'klass', {}, 0)
        job = self.lua('pop', 1, 'queue', 'worker', 10)[0]
        self.assertEqual(self.lua('workers', 2, 'worker'), {

src/q/l/qless-py-0.10.1/test/test_config.py   qless-py(Download)
    def test_set_get_unset(self):
        '''Basic set/get/unset'''
        self.assertEqual(self.client.config['foo'], None)
        self.client.config['foo'] = 5
        self.assertEqual(self.client.config['foo'], 5)
        del self.client.config['foo']
        self.assertEqual(self.client.config['foo'], None)
    def test_get_all(self):
        '''Ensure we can get all the configuration'''
        self.assertEqual(self.client.config.all, {
            'application': 'qless',
            'grace-period': 10,
            self.client.config[key] = 1
        for value in self.client.config.values():
            self.assertEqual(value, '1')
        self.client.config.clear()
        self.assertEqual(self.client.config.all, original)

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'], [
        for index in range(100):
            self.lua('put', index, 'worker', 'queue', 'jid', 'klass', {}, 0)
        self.assertEqual(self.lua('get', 0, 'jid')['history'], [
            {'q': 'queue', 'what': 'put', 'when': 0},
            {'q': 'queue', 'what': 'put', 'when': 96},
        self.lua('put', 3, 'worker', 'queue', 'jid', 'klass', {}, 0)
        self.lua('pop', 4, 'queue', 'worker', 10)
        self.assertEqual(self.lua('get', 5, 'jid')['failure'], {
            'group': 'group',
            'message': 'message',
            'when': 2,
            'worker': 'worker'})
        self.lua('complete', 6, 'jid', 'worker', 'queue', {})
        self.assertEqual(self.lua('get', 7, 'jid')['failure'], {})
        self.lua('pop', 1, 'queue', 'worker', 10)
        self.lua('complete', 2, 'jid', 'worker', 'queue', {})
        self.assertEqual(self.lua('get', 3, 'jid'), {
            'data': '{}',
            'dependencies': {},

  1 | 2 | 3  Next