Beispiel #1
0
 def results_url(self):
     if not self.task:
         url = results2.GetCachedResults2(self)
         if url:
             return url
     # Point to the default status page if no results are available.
     return '/results2/%s' % self.job_id
    def testGetCachedResults2_Uncached_Fails(self, mock_cloudstorage):
        mock_cloudstorage.return_value = []

        job = _JobStub(_JOB_WITH_DIFFERENCES, '123')
        url = results2.GetCachedResults2(job)

        self.assertIsNone(url)
Beispiel #3
0
    def get(self, job_id):
        try:
            job = job_module.JobFromId(job_id)
            if not job:
                raise results2.Results2Error('Error: Unknown job %s' % job_id)

            if not job.completed:
                self.response.out.write(
                    json.dumps({'status': 'job-incomplete'}))
                return

            url = results2.GetCachedResults2(job)
            if url:
                self.response.out.write(
                    json.dumps({
                        'status': 'complete',
                        'url': url,
                        'updated': job.updated.isoformat(),
                    }))
                return

            if results2.ScheduleResults2Generation(job):
                self.response.out.write(json.dumps({'status': 'pending'}))
                return

            self.response.out.write(json.dumps({'status': 'failed'}))

        except results2.Results2Error as e:
            self.response.set_status(400)
            self.response.out.write(e.message)
    def testGetCachedResults2_Cached_ReturnsResult(self, mock_cloudstorage):
        mock_cloudstorage.return_value = ['foo']

        job = _JobStub(_JOB_WITH_DIFFERENCES, '123')
        url = results2.GetCachedResults2(job)

        self.assertEqual(
            'https://storage.cloud.google.com/results2-public/'
            '%s.html' % job.job_id, url)