Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: dashboard/dashboard/pinpoint/handlers/jobs_test.py

Issue 3002903002: [pinpoint] Refactor Quest Generator. (Closed)
Patch Set: Comments Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | dashboard/dashboard/pinpoint/handlers/new.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import unittest 6 import unittest
7 7
8 import webapp2 8 import webapp2
9 import webtest 9 import webtest
10 10
11 from google.appengine.ext import ndb 11 from google.appengine.ext import ndb
12 from google.appengine.ext import testbed 12 from google.appengine.ext import testbed
13 13
14 from dashboard.pinpoint.handlers import jobs 14 from dashboard.pinpoint.handlers import jobs
15 from dashboard.pinpoint.models import job as job_module 15 from dashboard.pinpoint.models import job as job_module
16 from dashboard.pinpoint.models import quest_generator
17 16
18 17
19 class JobsTest(unittest.TestCase): 18 class JobsTest(unittest.TestCase):
20 19
21 def setUp(self): 20 def setUp(self):
22 app = webapp2.WSGIApplication([ 21 app = webapp2.WSGIApplication([
23 webapp2.Route(r'/jobs', jobs.Jobs), 22 webapp2.Route(r'/jobs', jobs.Jobs),
24 ]) 23 ])
25 self.testapp = webtest.TestApp(app) 24 self.testapp = webtest.TestApp(app)
26 self.testapp.extra_environ.update({'REMOTE_ADDR': 'remote_ip'}) 25 self.testapp.extra_environ.update({'REMOTE_ADDR': 'remote_ip'})
27 26
28 self.testbed = testbed.Testbed() 27 self.testbed = testbed.Testbed()
29 self.testbed.activate() 28 self.testbed.activate()
30 self.testbed.init_datastore_v3_stub() 29 self.testbed.init_datastore_v3_stub()
31 self.testbed.init_memcache_stub() 30 self.testbed.init_memcache_stub()
32 ndb.get_context().clear_cache() 31 ndb.get_context().clear_cache()
33 32
34 def tearDown(self): 33 def tearDown(self):
35 self.testbed.deactivate() 34 self.testbed.deactivate()
36 35
37 def testPost_ValidRequest(self): 36 def testPost_ValidRequest(self):
38 # Create job. 37 # Create job.
39 generator = quest_generator.QuestGenerator({
40 'configuration': 'chromium-rel-mac11-pro',
41 'target': 'telemetry_perf_tests',
42 'dimensions': '{}',
43 'benchmark': 'speedometer',
44 })
45 job = job_module.Job.New( 38 job = job_module.Job.New(
46 arguments=generator.AsDict(), 39 arguments={},
47 quests=generator.Quests(), 40 quests=(),
48 auto_explore=True, 41 auto_explore=True,
49 bug_id=None) 42 bug_id=None)
50 job.put() 43 job.put()
51 44
52 data = json.loads(self.testapp.post('/jobs').body) 45 data = json.loads(self.testapp.post('/jobs').body)
53 46
54 self.assertEqual(1, data['jobs_count']) 47 self.assertEqual(1, data['jobs_count'])
55 self.assertEqual(1, len(data['jobs_list'])) 48 self.assertEqual(1, len(data['jobs_list']))
56 self.assertEqual(job.AsDict(), data['jobs_list'][0]) 49 self.assertEqual(job.AsDict(), data['jobs_list'][0])
OLDNEW
« no previous file with comments | « no previous file | dashboard/dashboard/pinpoint/handlers/new.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698