|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -import unittest |
16 | | - |
17 | 15 | # from the app main.py |
18 | 16 | from datastore.ndb.transactions import main |
19 | 17 |
|
20 | | -from google.appengine.datastore import datastore_stub_util |
21 | | -from google.appengine.ext import testbed |
22 | | - |
| 18 | +from tests import DatastoreTestbed |
23 | 19 |
|
24 | 20 |
|
25 | | -class TestHandlers(unittest.TestCase): |
| 21 | +class TestHandlers(DatastoreTestbed): |
26 | 22 | def setUp(self): |
27 | | - """Setup the datastore and memcache stub.""" |
28 | | - # First, create an instance of the Testbed class. |
29 | | - self.testbed = testbed.Testbed() |
30 | | - # Then activate the testbed, which prepares the service stubs for |
31 | | - # use. |
32 | | - self.testbed.activate() |
33 | | - # Create a consistency policy that will simulate the High |
34 | | - # Replication consistency model. |
35 | | - self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy( |
36 | | - probability=0) |
37 | | - # Initialize the datastore stub with this policy. |
38 | | - self.testbed.init_datastore_v3_stub(consistency_policy=self.policy) |
39 | | - self.testbed.init_memcache_stub() |
40 | | - |
| 23 | + super(TestHandlers, self).setUp() |
| 24 | + self.testbed.init_taskqueue_stub() |
41 | 25 | main.app.config['TESTING'] = True |
42 | 26 | self.app = main.app.test_client() |
43 | 27 |
|
44 | | - def tearDown(self): |
45 | | - self.testbed.deactivate() |
46 | | - |
47 | 28 | def test_hello(self): |
48 | 29 | rv = self.app.get('/') |
49 | 30 | self.assertIn('Permenant note page', rv.data) |
|
0 commit comments