Esempio n. 1
0
 def test_only_admin_can_access(self):
     self.client.logout()
     assert self.client.login(email="*****@*****.**", roles=[roles.DJ])
     r = self.client.post(reverse("jobs.start"), data={"job_name": "build-trafficlog-report"})
     eq_(r.status_code, 403)
     job = Job(job_name="build-trafficlog-report")
     job.put()
     r = self.client.post(reverse("jobs.work"), data={"job_key": job.key(), "params": "{}"})
     eq_(r.status_code, 403)
     r = self.client.post(reverse("jobs.product", args=[str(job.key())]))
     eq_(r.status_code, 403)
Esempio n. 2
0
 def test_only_admin_can_access(self):
     self.client.logout()
     assert self.client.login(email="*****@*****.**",
                              roles=[roles.DJ])
     r = self.client.post(reverse('jobs.start'),
                          data={'job_name': 'build-trafficlog-report'})
     eq_(r.status_code, 403)
     job = Job(job_name='build-trafficlog-report')
     job.put()
     r = self.client.post(reverse('jobs.work'),
                          data={'job_key': job.key(),
                                'params': '{}'})
     eq_(r.status_code, 403)
     r = self.client.post(reverse('jobs.product', args=[str(job.key())]))
     eq_(r.status_code, 403)
Esempio n. 3
0
 def test_only_admin_can_access(self):
     self.client.logout()
     assert self.client.login(email="*****@*****.**", roles=[roles.DJ])
     r = self.client.post(reverse('jobs.start'),
                          data={'job_name': 'build-trafficlog-report'})
     eq_(r.status_code, 403)
     job = Job(job_name='build-trafficlog-report')
     job.put()
     r = self.client.post(reverse('jobs.work'),
                          data={
                              'job_key': job.key(),
                              'params': '{}'
                          })
     eq_(r.status_code, 403)
     r = self.client.post(reverse('jobs.product', args=[str(job.key())]))
     eq_(r.status_code, 403)
Esempio n. 4
0
 def test_work(self):
     job = Job(job_name='some-job')
     job.put()
     response = self.client.post(reverse('jobs.work'), {
         'job_key': str(job.key()),
         'params': '{}'
     })
     self.assertEqual(response.status_code, 403)
Esempio n. 5
0
 def test_work(self):
     job = Job(job_name='some-job')
     job.put()
     response = self.client.post(reverse('jobs.work'), {
         'job_key': str(job.key()),
         'params': '{}'
     })
     self.assertEqual(response.status_code, 403)
Esempio n. 6
0
 def test_get_nonexistant_job_product(self):
     # make a deleted job:
     job = Job(job_name="counter")
     job.save()
     job_key = job.key()
     job.delete()
     
     response = self.client.get(reverse('jobs.product', args=(job_key,)))
     self.assertEqual(response.status_code, 404)
Esempio n. 7
0
    def test_get_nonexistant_job_product(self):
        # make a deleted job:
        job = Job(job_name="counter")
        job.save()
        job_key = job.key()
        job.delete()

        response = self.client.get(reverse('jobs.product', args=(job_key, )))
        self.assertEqual(response.status_code, 404)
Esempio n. 8
0
    def test_job_reaper_kills_old_jobs(self):
        # make an old job:
        job = Job(job_name='counter')
        job.started = datetime.datetime.now() - timedelta(days=3)
        job.save()
        old_job_key = job.key()

        response = self.client.post(reverse('jobs.start'),
                                    {'job_name': 'counter'})
        json_response = simplejson.loads(response.content)
        self.assert_json_success(json_response)

        self.assertEqual(Job.get(old_job_key), None)
Esempio n. 9
0
 def test_job_reaper_kills_old_jobs(self):
     # make an old job:
     job = Job(job_name='counter')
     job.started = datetime.datetime.now() - timedelta(days=3)
     job.save()
     old_job_key = job.key()
     
     response = self.client.post(reverse('jobs.start'), {
         'job_name': 'counter'
     })
     json_response = simplejson.loads(response.content)
     self.assert_json_success(json_response)
     
     self.assertEqual(Job.get(old_job_key), None)
Esempio n. 10
0
 def test_product(self):
     job = Job(job_name='some-job')
     job.put()
     response = self.client.get(reverse('jobs.product',
                                args=[str(job.key())]))
     self.assertEqual(response.status_code, 403)
Esempio n. 11
0
 def test_product(self):
     job = Job(job_name='some-job')
     job.put()
     response = self.client.get(
         reverse('jobs.product', args=[str(job.key())]))
     self.assertEqual(response.status_code, 403)