Exemple #1
0
def schedule():
  if request.method == 'GET':
    return jsonify({'success': False})

  message_id = request.form.get('m_id', None)
  subject = request.form.get('subj', None)
  if message_id:
    print 'Scheduling bump...'
    print '\tsubject:', subject
    print '\tmessage id:', message_id
    scheduled_for = datetime.datetime.now() + datetime.timedelta(days=5)  # TODO
    jobs.add(subject, message_id, scheduled_for)


  return jsonify({'success': True})
Exemple #2
0
def schedule():
    if request.method == 'GET':
        return jsonify({'success': False})

    message_id = request.form.get('m_id', None)
    subject = request.form.get('subj', None)
    if message_id:
        print 'Scheduling bump...'
        print '\tsubject:', subject
        print '\tmessage id:', message_id
        scheduled_for = datetime.datetime.now() + datetime.timedelta(
            days=5)  # TODO
        jobs.add(subject, message_id, scheduled_for)

    return jsonify({'success': True})
Exemple #3
0
 def test_get_jobs_info_filter(self):
     foo = FooJob()
     jobs.add(foo)
     bar = BarJob()
     jobs.add(bar)
     self.assertEqual({bar.id: bar.info()}, jobs.info(bar.job_type))
Exemple #4
0
 def test_get_job(self):
     job = TestingJob()
     jobs.add(job)
     self.assertEqual(job.id, jobs.get(job.id).id)
Exemple #5
0
 def test_get_jobs_info(self):
     foo = FooJob()
     jobs.add(foo)
     bar = BarJob()
     jobs.add(bar)
     self.assertEqual({foo.id: foo.info(), bar.id: bar.info()}, jobs.info())
Exemple #6
0
 def test_add_existing_job(self):
     job = TestingJob()
     jobs.add(job)
     self.assertRaises(jobs.JobExistsError, jobs.add, job)
Exemple #7
0
 def test_add_job(self):
     job = TestingJob()
     jobs.add(job)
     self.assertEqual(1, len(jobs._jobs))
Exemple #8
0
 def test_delete_running_job(self):
     job = TestingJob()
     jobs.add(job)
     self.assertEqual(response.error(jobs.JobNotDone.name), jobs.delete(job.id))
Exemple #9
0
 def test_delete_job(self, status):
     job = TestingJob()
     job._status = status
     jobs.add(job)
     self.assertEqual(response.success(), jobs.delete(job.id))
Exemple #10
0
 def test_abort_job(self):
     job = TestingJob()
     jobs.add(job)
     jobs.abort(job.id)
     self.assertEqual(jobs.STATUS.ABORTED, job.status)
     self.assertTrue(job._aborted)