def test_job_log_stderr(self): daemon.dispatch_job('test', config['__file__'], 'test_stderr') while daemon.job_running('test'): time.sleep(0.1) h.assert_equal(daemon.job_log('test'), 'Text to standard error\n')
def test_dispatch_job_nonexistent_task(self): daemon.dispatch_job('test', config['__file__'], 'test_nonexistent') while daemon.job_running('test'): time.sleep(0.1) assert 'TaskNotFoundError' in daemon.job_log('test'), \ "TaskNotFoundError not in job log for nonexistent task!"
def test_args(self): args = ('one', '123', 'abc') daemon.dispatch_job('test', config['__file__'], 'test_args', args) while daemon.job_running('test'): time.sleep(0.1) h.assert_equal(daemon.job_log('test'), "('one', '123', 'abc')\n")
def drop_database(self): c.job_id = 'drop_database' if daemon.job_running(c.job_id): return render('task/drop_database.html') daemon.dispatch_job( job_id=c.job_id, config=config['__file__'], task='drop_collections' ) return redirect(url(controller='job', action='status', job_id=c.job_id))
def remove_dataset(self, dataset=None): if dataset is None: c.datasets = model.Dataset.find() return render('task/remove_dataset.html') c.job_id = 'remove_%s' % dataset c.job_running = daemon.job_running(c.job_id) if c.job_running: return render('task/remove_dataset.html') daemon.dispatch_job( job_id=c.job_id, config=config['__file__'], task='remove_dataset', args=(dataset,) ) return redirect(url(controller='job', action='status', job_id=c.job_id))
def start(self, package): job_id = _job_id_for_package(package) if daemon.job_running(job_id): c.pkg_name = package c.job_id = job_id return render('load/start.html') else: daemon.dispatch_job( job_id=job_id, config=config['__file__'], task='ckan_import', args=(package,) ) return redirect(url( controller='job', action='status', job_id=job_id ))
def test_dispatch_job(self): daemon.dispatch_job('test', config['__file__'], 'test_noop')
def test_dispatch_when_locked(self): self.pidlockfile_obj.locked = True daemon.dispatch_job('test', config['__file__'], 'test_noop')
def test_dispatch_job_nonexistent_task(self): daemon.dispatch_job('test', config['__file__'], 'test_nonexistent')
def test_args(self): args = ('one', '123', 'abc') daemon.dispatch_job('test', config['__file__'], 'test_args', args) h.assert_equal(self.daemoncontext_obj.stdout.getvalue(), "('one', '123', 'abc')\n")
def test_job_log_stderr(self): daemon.dispatch_job('test', config['__file__'], 'test_stderr') h.assert_equal(self.daemoncontext_obj.stderr.getvalue(), 'Text to standard error\n')