def setUp(self): self.app_id = 'myapp' os.environ['APPLICATION_ID'] = self.app_id # Use a consistent replication strategy so that the test can use queries # to verify that an entity was written. consistent_policy = datastore_stub_util.MasterSlaveConsistencyPolicy() api_server.test_setup_stubs(app_id=self.app_id, datastore_consistency=consistent_policy) self.mox = mox.Mox() self.mox.StubOutWithMock(admin_request_handler.AdminRequestHandler, 'render') self.entity1 = datastore.Entity('Kind1', id=123, _app=self.app_id) self.entity1['intprop'] = 1 self.entity1['listprop'] = [7, 8, 9] self.entity1['dateprop'] = datastore_types._OverflowDateTime(2**60) datastore.Put(self.entity1) self.entity2 = datastore.Entity('Kind1', id=124, _app=self.app_id) self.entity2['stringprop'] = 'value2' self.entity2['listprop'] = [4, 5, 6] datastore.Put(self.entity2) self.entity3 = datastore.Entity('Kind1', id=125, _app=self.app_id) self.entity3['intprop'] = 3 self.entity3['listprop'] = [1, 2, 3] datastore.Put(self.entity3) self.entity4 = datastore.Entity('Kind1', id=126, _app=self.app_id) self.entity4['intprop'] = 4 self.entity4['stringprop'] = 'value4' self.entity4['listprop'] = [10, 11] datastore.Put(self.entity4)
def setUp(self): self.mox = mox.Mox() api_server.test_setup_stubs() self.dispatch_config = DispatchConfigurationStub() app_config = ApplicationConfigurationStub(MODULE_CONFIGURATIONS) self.dispatcher = _make_dispatcher(app_config) self.module1 = AutoScalingModuleFacade(app_config.modules[0], balanced_port=1, host='localhost') self.module2 = ManualScalingModuleFacade(app_config.modules[0], balanced_port=2, host='localhost') self.module3 = ManualScalingModuleFacade(app_config.modules[0], balanced_port=3, host='0.0.0.0') self.mox.StubOutWithMock(self.dispatcher, '_create_module') self.dispatcher._create_module(app_config.modules[0], 1).AndReturn( (self.module1, 2)) self.dispatcher._create_module(app_config.modules[1], 2).AndReturn( (self.module2, 3)) self.dispatcher._create_module(app_config.modules[2], 3).AndReturn( (self.module3, 4)) self.mox.ReplayAll() self.dispatcher.start('localhost', 12345, object()) app_config.dispatch = self.dispatch_config self.mox.VerifyAll() self.mox.StubOutWithMock(module.Module, 'build_request_environ')
def setUp(self): self.app_id = 'myapp' os.environ['APPLICATION_ID'] = self.app_id # Use a consistent replication strategy so the puts done in the test code # are seen immediately by the queries under test. consistent_policy = datastore_stub_util.MasterSlaveConsistencyPolicy() api_server.test_setup_stubs( app_id=self.app_id, datastore_consistency=consistent_policy) self.entity1 = datastore.Entity('Kind1', id=123, _app=self.app_id) self.entity1['intprop'] = 1 self.entity1['listprop'] = [7, 8, 9] datastore.Put(self.entity1) self.entity2 = datastore.Entity('Kind1', id=124, _app=self.app_id) self.entity2['stringprop'] = 'value2' self.entity2['listprop'] = [4, 5, 6] datastore.Put(self.entity2) self.entity3 = datastore.Entity('Kind1', id=125, _app=self.app_id) self.entity3['intprop'] = 3 self.entity3['listprop'] = [1, 2, 3] datastore.Put(self.entity3) self.entity4 = datastore.Entity('Kind1', id=126, _app=self.app_id) self.entity4['intprop'] = 4 self.entity4['stringprop'] = 'value4' self.entity4['listprop'] = [10, 11] datastore.Put(self.entity4)
def setUp(self): self.mox = mox.Mox() api_server.test_setup_stubs() self.dispatch_config = DispatchConfigurationStub() app_config = ApplicationConfigurationStub(MODULE_CONFIGURATIONS) self.dispatcher = dispatcher.Dispatcher(app_config, 'localhost', 1, 'gmail.com', 1, 'php_executable_path', 'enable_php_remote_debugging', python_config=None, cloud_sql_config=None, module_to_max_instances={}, use_mtime_file_watcher=False, automatic_restart=True, allow_skipped_files=False) self.module1 = AutoScalingModuleFacade(app_config.modules[0], balanced_port=1, host='localhost') self.module2 = ManualScalingModuleFacade(app_config.modules[0], balanced_port=2, host='localhost') self.mox.StubOutWithMock(self.dispatcher, '_create_module') self.dispatcher._create_module(app_config.modules[0], 1).AndReturn( (self.module1, 2)) self.dispatcher._create_module(app_config.modules[1], 2).AndReturn( (self.module2, 3)) self.mox.ReplayAll() self.dispatcher.start(12345, object()) app_config.dispatch = self.dispatch_config self.mox.VerifyAll() self.mox.StubOutWithMock(module.Module, 'build_request_environ')
def setUp(self): self.mox = mox.Mox() api_server.test_setup_stubs() self.dispatch_config = DispatchConfigurationStub() app_config = ApplicationConfigurationStub(SERVER_CONFIGURATIONS) self.dispatcher = dispatcher.Dispatcher(app_config, 'localhost', 1, 1, python_config=None, cloud_sql_config=None, server_to_max_instances={}, use_mtime_file_watcher=False, automatic_restart=True) self.server1 = AutoScalingServerFacade(app_config.servers[0], balanced_port=1, host='localhost') self.server2 = ManualScalingServerFacade(app_config.servers[0], balanced_port=2, host='localhost') self.mox.StubOutWithMock(self.dispatcher, '_create_server') self.dispatcher._create_server(app_config.servers[0], 1).AndReturn( (self.server1, 2)) self.dispatcher._create_server(app_config.servers[1], 2).AndReturn( (self.server2, 3)) self.mox.ReplayAll() self.dispatcher.start(12345, object()) app_config.dispatch = self.dispatch_config self.mox.VerifyAll() self.mox.StubOutWithMock(server.Server, 'build_request_environ')
def setUp(self): self.mox = mox.Mox() api_server.test_setup_stubs() self.dispatch_config = DispatchConfigurationStub() app_config = ApplicationConfigurationStub(MODULE_CONFIGURATIONS) self.dispatcher = _make_dispatcher(app_config) self.module1 = AutoScalingModuleFacade(app_config.modules[0], balanced_port=1, host='localhost') self.module2 = ManualScalingModuleFacade(app_config.modules[0], balanced_port=2, host='localhost') self.module3 = ManualScalingModuleFacade(app_config.modules[0], balanced_port=3, host='0.0.0.0') self.mox.StubOutWithMock(self.dispatcher, '_create_module') self.dispatcher._create_module(app_config.modules[0], 1).AndReturn( (self.module1, 2)) self.dispatcher._create_module(app_config.modules[1], 2).AndReturn( (self.module2, 3)) self.dispatcher._create_module(app_config.modules[2], 3).AndReturn( (self.module3, 4)) self.mox.ReplayAll() self.dispatcher.start('localhost', 12345, object()) app_config.dispatch = self.dispatch_config self.mox.VerifyAll() self.mox.StubOutWithMock(module.Module, 'build_request_environ')
def setup_stubs(): """Setup the API stubs. This can only be done once.""" api_server.test_setup_stubs( request_data, app_id=APP_ID, application_root=APPLICATION_ROOT, trusted=TRUSTED, blobstore_path=BLOBSTORE_PATH, datastore_consistency=datastore_stub_util.TimeBasedHRConsistencyPolicy(), datastore_path=DATASTORE_PATH, datastore_require_indexes=DATASTORE_REQUIRE_INDEXES, images_host_prefix=IMAGES_HOST_PREFIX, logs_path=':memory:', mail_smtp_host=MAIL_SMTP_HOST, mail_smtp_port=MAIL_SMTP_PORT, mail_smtp_user=MAIL_SMTP_USER, mail_smtp_password=MAIL_SMTP_PASSWORD, mail_enable_sendmail=MAIL_ENABLE_SENDMAIL, mail_show_mail_body=MAIL_SHOW_MAIL_BODY, matcher_prospective_search_path=MATCHER_PROSPECTIVE_SEARCH_PATH, taskqueue_auto_run_tasks=TASKQUEUE_AUTO_RUN_TASKS, taskqueue_default_http_server=TASKQUEUE_DEFAULT_HTTP_SERVER, user_login_url=USER_LOGIN_URL, user_logout_url=USER_LOGOUT_URL) apiproxy_stub_map.apiproxy.ReplaceStub( 'urlfetch', FakeURLFetchServiceStub()) apiproxy_stub_map.apiproxy.ReplaceStub( 'datastore_v4', FakeDatastoreV4ServiceStub())
def setup_stubs(): """Setup the API stubs. This can only be done once.""" api_server.test_setup_stubs( request_data, app_id=APP_ID, application_root=APPLICATION_ROOT, trusted=TRUSTED, blobstore_path=BLOBSTORE_PATH, datastore_consistency=datastore_stub_util.TimeBasedHRConsistencyPolicy(), datastore_path=DATASTORE_PATH, datastore_require_indexes=DATASTORE_REQUIRE_INDEXES, images_host_prefix=IMAGES_HOST_PREFIX, logs_path=':memory:', mail_smtp_host=MAIL_SMTP_HOST, mail_smtp_port=MAIL_SMTP_PORT, mail_smtp_user=MAIL_SMTP_USER, mail_smtp_password=MAIL_SMTP_PASSWORD, mail_enable_sendmail=MAIL_ENABLE_SENDMAIL, mail_show_mail_body=MAIL_SHOW_MAIL_BODY, matcher_prospective_search_path=MATCHER_PROSPECTIVE_SEARCH_PATH, taskqueue_auto_run_tasks=TASKQUEUE_AUTO_RUN_TASKS, taskqueue_default_http_server=TASKQUEUE_DEFAULT_HTTP_SERVER, user_login_url=USER_LOGIN_URL, user_logout_url=USER_LOGOUT_URL) apiproxy_stub_map.apiproxy.ReplaceStub('urlfetch', FakeURLFetchServiceStub())
def setUp(self): self.mox = mox.Mox() api_server.test_setup_stubs() app_config = ApplicationConfigurationStub(SERVER_CONFIGURATIONS) self.dispatcher = dispatcher.Dispatcher(app_config, 'localhost', 1, cloud_sql_config=None) self.server1 = AutoScalingServerFacade(app_config.servers[0], balanced_port=1, host='localhost') self.server2 = ManualScalingServerFacade(app_config.servers[0], balanced_port=2, host='localhost') self.mox.StubOutWithMock(self.dispatcher, '_create_server') self.dispatcher._create_server(app_config.servers[0], 1).AndReturn( (self.server1, 2)) self.dispatcher._create_server(app_config.servers[1], 2).AndReturn( (self.server2, 3)) self.mox.ReplayAll() self.dispatcher.start(12345, object()) self.mox.VerifyAll() self.mox.StubOutWithMock(server.Server, 'build_request_environ')
def setUp(self): self.app_id = 'myapp' os.environ['APPLICATION_ID'] = self.app_id # Use a consistent replication strategy so the puts done in the test code # are seen immediately by the queries under test. consistent_policy = datastore_stub_util.MasterSlaveConsistencyPolicy() api_server.test_setup_stubs(app_id=self.app_id, datastore_consistency=consistent_policy) self.entity1 = datastore.Entity('Kind1', id=123, _app=self.app_id) self.entity1['intprop'] = 1 self.entity1['listprop'] = [7, 8, 9] datastore.Put(self.entity1) self.entity2 = datastore.Entity('Kind1', id=124, _app=self.app_id) self.entity2['stringprop'] = 'value2' self.entity2['listprop'] = [4, 5, 6] datastore.Put(self.entity2) self.entity3 = datastore.Entity('Kind1', id=125, _app=self.app_id) self.entity3['intprop'] = 3 self.entity3['listprop'] = [1, 2, 3] datastore.Put(self.entity3) self.entity4 = datastore.Entity('Kind1', id=126, _app=self.app_id) self.entity4['intprop'] = 4 self.entity4['stringprop'] = 'value4' self.entity4['listprop'] = [10, 11] datastore.Put(self.entity4)
def setUp(self): self.app_id = 'myapp' os.environ['APPLICATION_ID'] = self.app_id # Use a consistent replication strategy so that the test can use queries # to verify that an entity was written. consistent_policy = datastore_stub_util.MasterSlaveConsistencyPolicy() api_server.test_setup_stubs( app_id=self.app_id, datastore_consistency=consistent_policy) self.mox = mox.Mox() self.mox.StubOutWithMock(admin_request_handler.AdminRequestHandler, 'render') self.entity1 = datastore.Entity('Kind1', id=123, _app=self.app_id) self.entity1['intprop'] = 1 self.entity1['listprop'] = [7, 8, 9] datastore.Put(self.entity1) self.entity2 = datastore.Entity('Kind1', id=124, _app=self.app_id) self.entity2['stringprop'] = 'value2' self.entity2['listprop'] = [4, 5, 6] datastore.Put(self.entity2) self.entity3 = datastore.Entity('Kind1', id=125, _app=self.app_id) self.entity3['intprop'] = 3 self.entity3['listprop'] = [1, 2, 3] datastore.Put(self.entity3) self.entity4 = datastore.Entity('Kind1', id=126, _app=self.app_id) self.entity4['intprop'] = 4 self.entity4['stringprop'] = 'value4' self.entity4['listprop'] = [10, 11] datastore.Put(self.entity4)
def setUp(self): self.app_id = 'myapp' os.environ['APPLICATION_ID'] = self.app_id api_server.test_setup_stubs(app_id=self.app_id) self.mox = mox.Mox() self.mox.StubOutWithMock(admin_request_handler.AdminRequestHandler, 'render')
def setUp(self): self.app_id = 'myapp' os.environ['APPLICATION_ID'] = self.app_id api_server.test_setup_stubs(app_id=self.app_id) self.mox = mox.Mox() self.mox.StubOutWithMock(admin_request_handler.AdminRequestHandler, 'render')
def setUp(self): self.app_id = 'myapp' os.environ['APPLICATION_ID'] = self.app_id # Use a consistent replication strategy so the puts done in the test code # are seen immediately by the queries under test. consistent_policy = datastore_stub_util.MasterSlaveConsistencyPolicy() api_server.test_setup_stubs( app_id=self.app_id, application_root=None, # Needed to allow index updates. datastore_consistency=consistent_policy)
def setUp(self): self.app_id = 'myapp' os.environ['APPLICATION_ID'] = self.app_id # Use a consistent replication strategy so the puts done in the test code # are seen immediately by the queries under test. consistent_policy = datastore_stub_util.MasterSlaveConsistencyPolicy() api_server.test_setup_stubs( app_id=self.app_id, application_root=None, # Needed to allow index updates. datastore_consistency=consistent_policy)
def main(argv): api_server.test_setup_stubs(app_id='_') parser = MakeParser(argv[0]) args = parser.parse_args(argv[1:]) application_path = getattr(args, 'application', None) if application_path is not None: sys.path.insert(0, os.path.abspath(application_path)) args.callback(args)
def main(argv): api_server.test_setup_stubs(app_id='_') parser = MakeParser(argv[0]) args = parser.parse_args(argv[1:]) application_path = getattr(args, 'application', None) if application_path is not None: sys.path.insert(0, os.path.abspath(application_path)) args.callback(args)
def setUp(self): self.mox = mox.Mox() api_server.test_setup_stubs() self.dispatch_config = DispatchConfigurationStub() app_config = ApplicationConfigurationStub(MODULE_CONFIGURATIONS) self.dispatcher = dispatcher.Dispatcher( app_config, 'localhost', 1, 'gmail.com', 1, 'php_executable_path', 'enable_php_remote_debugging', python_config=None, cloud_sql_config=None, module_to_max_instances={}, use_mtime_file_watcher=False, automatic_restart=True, allow_skipped_files=False, module_to_threadsafe_override={}) self.module1 = AutoScalingModuleFacade(app_config.modules[0], balanced_port=1, host='localhost') self.module2 = ManualScalingModuleFacade(app_config.modules[0], balanced_port=2, host='localhost') self.mox.StubOutWithMock(self.dispatcher, '_create_module') self.dispatcher._create_module(app_config.modules[0], 1).AndReturn( (self.module1, 2)) self.dispatcher._create_module(app_config.modules[1], 2).AndReturn( (self.module2, 3)) self.mox.ReplayAll() self.dispatcher.start(12345, object()) app_config.dispatch = self.dispatch_config self.mox.VerifyAll() self.mox.StubOutWithMock(module.Module, 'build_request_environ')
#!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "gaemeta.settings") PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) import wrapper_util dir_path = wrapper_util.get_dir_path('wrapper_util.py', os.path.join('lib', 'ipaddr')) paths = wrapper_util.Paths(dir_path) sys.path[1:1] = paths.script_paths('dev_appserver.py') import yaml conf = yaml.load(open('app.yaml')) app_id = "dev~{}".format(conf['application']) os.environ.setdefault("APPLICATION_ID", app_id) from google.appengine.tools.devappserver2 import api_server api_server.test_setup_stubs(app_id=app_id, application_root=PROJECT_DIR, datastore_path='/var/db/gaedata/datastore.db') from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)