| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 unittest | 5 import unittest |
| 6 | 6 |
| 7 from google.appengine.ext import ndb | 7 from google.appengine.ext import ndb |
| 8 from google.appengine.ext import testbed | 8 from google.appengine.ext import testbed |
| 9 | 9 |
| 10 from dashboard.pinpoint.models import change | 10 from dashboard.pinpoint.models import change |
| 11 from dashboard.pinpoint.models import isolate | 11 from dashboard.pinpoint.models import isolate |
| 12 | 12 |
| 13 | 13 |
| 14 _CHANGE_1 = change.Change(change.Dep('chromium', 'f9f2b720')) | 14 _CHANGE_1 = change.Change((change.Commit('chromium', 'f9f2b720'),)) |
| 15 _CHANGE_2 = change.Change(change.Dep('chromium', 'f35be4f1')) | 15 _CHANGE_2 = change.Change((change.Commit('chromium', 'f35be4f1'),)) |
| 16 | 16 |
| 17 | 17 |
| 18 class IsolateTest(unittest.TestCase): | 18 class IsolateTest(unittest.TestCase): |
| 19 | 19 |
| 20 def setUp(self): | 20 def setUp(self): |
| 21 self.testbed = testbed.Testbed() | 21 self.testbed = testbed.Testbed() |
| 22 self.testbed.activate() | 22 self.testbed.activate() |
| 23 self.testbed.init_datastore_v3_stub() | 23 self.testbed.init_datastore_v3_stub() |
| 24 self.testbed.init_memcache_stub() | 24 self.testbed.init_memcache_stub() |
| 25 ndb.get_context().clear_cache() | 25 ndb.get_context().clear_cache() |
| 26 | 26 |
| 27 def tearDown(self): | 27 def tearDown(self): |
| 28 self.testbed.deactivate() | 28 self.testbed.deactivate() |
| 29 | 29 |
| 30 def testPutAndGet(self): | 30 def testPutAndGet(self): |
| 31 isolate.Put(( | 31 isolate.Put(( |
| 32 ('Mac Builder', _CHANGE_1, 'telemetry_perf', '7c7e90be'), | 32 ('Mac Builder', _CHANGE_1, 'telemetry_perf', '7c7e90be'), |
| 33 ('Mac Builder', _CHANGE_2, 'telemetry_perf', '38e2f262'))) | 33 ('Mac Builder', _CHANGE_2, 'telemetry_perf', '38e2f262'))) |
| 34 | 34 |
| 35 isolate_hash = isolate.Get('Mac Builder', _CHANGE_1, 'telemetry_perf') | 35 isolate_hash = isolate.Get('Mac Builder', _CHANGE_1, 'telemetry_perf') |
| 36 self.assertEqual(isolate_hash, '7c7e90be') | 36 self.assertEqual(isolate_hash, '7c7e90be') |
| 37 | 37 |
| 38 def testUnknownIsolate(self): | 38 def testUnknownIsolate(self): |
| 39 with self.assertRaises(KeyError): | 39 with self.assertRaises(KeyError): |
| 40 isolate.Get('Wrong Builder', _CHANGE_1, 'telemetry_perf') | 40 isolate.Get('Wrong Builder', _CHANGE_1, 'telemetry_perf') |
| OLD | NEW |