def setUp(self): helpers.patch_environ(self) helpers.patch(self, [ 'system.environment.is_running_on_app_engine', ]) self.mock.is_running_on_app_engine.return_value = False ndb_patcher.init() ndb_patcher.patch_ndb() self.populate_test_data()
def setUpClass(cls): logs.configure_for_tests() os.environ['HOST_INSTANCE_NAME'] = 'host' os.environ['HOST_INSTANCE_NUM'] = '0' os.environ['BOT_NAME'] = 'host-0' os.environ['LOCAL_DEVELOPMENT'] = 'True' os.environ['SOURCE_VERSION_OVERRIDE'] = 'VERSION' os.environ['CONFIG_DIR_OVERRIDE'] = os.path.abspath( os.path.join(os.environ['ROOT_DIR'], 'configs', 'test')) cert_location = os.path.join(TEST_LIBS_DATA_DIR, 'untrusted_cert.pem') key_location = os.path.join(TEST_LIBS_DATA_DIR, 'untrusted_key.pem') os.environ['UNTRUSTED_TLS_CERT_FOR_TESTING'] = cert_location os.environ['UNTRUSTED_TLS_KEY_FOR_TESTING'] = key_location cls.bot_proc, bot_root_dir = _create_test_bot() os.environ['TRUSTED_HOST'] = 'True' os.environ['WORKER_ROOT_DIR'] = bot_root_dir os.environ['WORKER_BOT_TMPDIR'] = os.path.join(bot_root_dir, 'bot_tmpdir') # Explicitly patch datastore.ndb here, as otherwise we patch # google.appengine.ext.ndb which is not what is imported everywhere. ndb_patcher.patch_ndb(ndb) environment.set_default_vars() data_types.HostWorkerAssignment(host_name='host', instance_num=0, worker_name='localhost', project_name='project', id='host-0').put() with open(cert_location) as f: cert_contents = f.read() with open(key_location) as f: key_contents = f.read() data_types.WorkerTlsCert(project_name='project', cert_contents=cert_contents, key_contents=key_contents, id='project').put() host.init()