Esempio n. 1
0
 def test_enqueue_queue(self):
     self.enqueue()
     self.enqueue(queue=u"my_queue")
     all_jobs = self.all_jobs()
     assert_equal(len(all_jobs), 2)
     assert_equal(all_jobs[0].origin, jobs.add_queue_name_prefix(jobs.DEFAULT_QUEUE_NAME))
     assert_equal(all_jobs[1].origin, jobs.add_queue_name_prefix(u"my_queue"))
Esempio n. 2
0
 def test_enqueue_queue(self):
     self.enqueue()
     self.enqueue(queue=u"my_queue")
     all_jobs = self.all_jobs()
     assert len(all_jobs) == 2
     assert all_jobs[0].origin == jobs.add_queue_name_prefix(
         jobs.DEFAULT_QUEUE_NAME)
     assert all_jobs[1].origin == jobs.add_queue_name_prefix(u"my_queue")
Esempio n. 3
0
 def test_enqueue_queue(self):
     self.enqueue()
     self.enqueue(queue=u"my_queue")
     all_jobs = self.all_jobs()
     assert len(all_jobs) == 2
     assert sorted(job.origin for job in all_jobs) == sorted([
         jobs.add_queue_name_prefix(jobs.DEFAULT_QUEUE_NAME),
         jobs.add_queue_name_prefix(u"my_queue")
     ])
Esempio n. 4
0
 def test_enqueue_queue(self):
     self.enqueue()
     self.enqueue(queue=u'my_queue')
     all_jobs = self.all_jobs()
     assert_equal(len(all_jobs), 2)
     assert_equal(all_jobs[0].origin,
                  jobs.add_queue_name_prefix(jobs.DEFAULT_QUEUE_NAME))
     assert_equal(all_jobs[1].origin,
                  jobs.add_queue_name_prefix(u'my_queue'))
def ensure_importing_queue_exists():
    '''
    This is a hack to get around the lack of rq Queue kwarg exposure from ckanext-rq. The default
    timeout for queues is 180 seconds in rq which is not long enough for our import tasks but the
    timeout parameter hasn't been exposed. This code creates a new queue in the ckanext-rq cache so
    that when enqueuing new jobs it is used rather than a default one. Once this bug has been fixed
    in ckan/ckanext-rq this code will be removed.

    The queue is only added if not already in existance so this is safe to call multiple times.
    '''
    name = jobs.add_queue_name_prefix(u'importing')
    if name not in jobs._queues:
        # set the timeout to 12 hours
        queue = rq.Queue(name, default_timeout=60 * 60 * 12, connection=jobs._connect())
        # add the queue to the queue cache
        jobs._queues[name] = queue
Esempio n. 6
0
 def test_queue_name_removal_with_prefix(self):
     plain = u"foobar"
     prefixed = jobs.add_queue_name_prefix(plain)
     assert jobs.remove_queue_name_prefix(prefixed) == plain
Esempio n. 7
0
 def test_queue_name_prefix_contains_site_id(self):
     prefix = jobs.add_queue_name_prefix(u"")
     assert config[u"ckan.site_id"] in prefix
Esempio n. 8
0
 def test_queue_name_removal_with_prefix(self):
     plain = u'foobar'
     prefixed = jobs.add_queue_name_prefix(plain)
     assert_equal(jobs.remove_queue_name_prefix(prefixed), plain)
Esempio n. 9
0
 def test_queue_name_prefix_contains_site_id(self):
     prefix = jobs.add_queue_name_prefix(u'')
     ok_(config[u'ckan.site_id'] in prefix)
Esempio n. 10
0
 def test_queue_name_removal_with_prefix(self):
     plain = u'foobar'
     prefixed = jobs.add_queue_name_prefix(plain)
     assert_equal(jobs.remove_queue_name_prefix(prefixed), plain)
Esempio n. 11
0
 def test_queue_name_prefix_contains_site_id(self):
     prefix = jobs.add_queue_name_prefix(u'')
     ok_(config[u'ckan.site_id'] in prefix)