@@ -0,0 +1,2445 @@
+import os%0Aimport unittest%0A%0Afrom google.appengine.ext import testbed%0Afrom google.appengine.datastore import datastore_stub_util%0A%0Aimport settings%0A%0A%0AHRD_CONSISTENCY = 1%0A%0A%0Aclass DatastoreTestCase(unittest.TestCase):%0A    %22%22%22Test case with stubbed high-replication datastore API. The datastore%0A    stub uses an optimistic, always-consistent policy, meaning writes will%0A    always apply.%0A    %22%22%22%0A%0A    def setUp(self):%0A        super(DatastoreTestCase, self).setUp()%0A%0A        self.original_environ = dict(os.environ)%0A%0A        os.environ%5B'TZ'%5D = 'UTC'%0A%0A        self.testbed = testbed.Testbed()%0A        self.testbed.activate()%0A        self.testbed.setup_env(app_id=settings.APP_ID)%0A%0A        self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(%0A            probability=HRD_CONSISTENCY)%0A        self.testbed.init_datastore_v3_stub(consistency_policy=self.policy)%0A%0A    def tearDown(self):%0A        super(DatastoreTestCase, self).tearDown()%0A        self.testbed.deactivate()%0A%0A        os.environ = self.original_environ%0A%0A%0Aclass MemcacheTestCase(unittest.TestCase):%0A    %22%22%22Test case with stubbed memcache API.%22%22%22%0A%0A    def setUp(self):%0A        super(MemcacheTestCase, self).setUp()%0A%0A        self.original_environ = dict(os.environ)%0A%0A        os.environ%5B'TZ'%5D = 'UTC'%0A%0A        self.testbed = testbed.Testbed()%0A        self.testbed.activate()%0A        self.testbed.init_memcache_stub()%0A%0A    def tearDown(self):%0A        super(MemcacheTestCase, self).tearDown()%0A        self.testbed.deactivate()%0A%0A        os.environ = self.original_environ%0A%0A%0Aclass DatastoreMemcacheTestCase(unittest.TestCase):%0A    %22%22%22Test case with stubbed datastore and memcache APIs. The datastore%0A    stub uses an optimistic, always-consistent policy, meaning writes will%0A    always apply.%0A    %22%22%22%0A%0A    def setUp(self):%0A        super(DatastoreMemcacheTestCase, self).setUp()%0A%0A        self.original_environ = dict(os.environ)%0A%0A        os.environ%5B'TZ'%5D = 'UTC'%0A%0A        self.testbed = testbed.Testbed()%0A        self.testbed.activate()%0A        self.testbed.setup_env(app_id=settings.APP_ID)%0A%0A        self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(%0A            probability=HRD_CONSISTENCY)%0A        self.testbed.init_datastore_v3_stub(consistency_policy=self.policy)%0A%0A        self.testbed.init_memcache_stub()%0A%0A    def tearDown(self):%0A        super(DatastoreMemcacheTestCase, self).tearDown()%0A        self.testbed.deactivate()%0A%0A        os.environ = self.original_environ%0A%0A

Add datastore and memcache stub test cases