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.setup_test_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)
Ejemplo n.º 2
0
def setup_stubs():
    """Setup the API stubs. This can only be done once."""
    api_server.setup_test_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,
        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())
Ejemplo n.º 3
0
    def setUp(self):
        self.mox = mox.Mox()
        api_server.setup_test_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.setup_test_stubs(
         app_id=self.app_id,
         application_root=None,  # Needed to allow index updates.
         datastore_consistency=consistent_policy)
Ejemplo n.º 5
0
def main(argv):
    api_server.setup_test_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.app_id = 'myapp'
        os.environ['APPLICATION_ID'] = self.app_id
        api_server.setup_test_stubs(app_id=self.app_id)

        self.mox = mox.Mox()
        self.mox.StubOutWithMock(admin_request_handler.AdminRequestHandler,
                                 'render')
        self.mox.StubOutWithMock(admin_request_handler.AdminRequestHandler,
                                 'get')
        self.mox.StubOutWithMock(admin_request_handler.AdminRequestHandler,
                                 'post')
    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.setup_test_stubs(app_id=self.app_id,
                                    datastore_consistency=consistent_policy)

        self.mox = mox.Mox()
        self.mox.StubOutWithMock(admin_request_handler.AdminRequestHandler,
                                 'render')
        self.mox.StubOutWithMock(admin_request_handler.AdminRequestHandler,
                                 'get')
        self.mox.StubOutWithMock(admin_request_handler.AdminRequestHandler,
                                 'post')
        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)

        self.entity5 = datastore.Entity('Kind1', id=127, _app=self.app_id)
        self.entity5['intprop'] = 0
        self.entity5['boolprop'] = False
        self.entity5['stringprop'] = ''
        self.entity5['floatprop'] = 0.0
        datastore.Put(self.entity5)