Exemplo n.º 1
0
    def setUp(self):
        self.mox = mox.Mox()
        stub_util.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.mox.StubOutWithMock(self.dispatcher._port_registry, 'has')
        self.dispatcher._port_registry.has(1).AndReturn(False)
        self.dispatcher._create_module(app_config.modules[0], 1,
                                       None).AndReturn(self.module1)
        self.dispatcher._port_registry.has(1).AndReturn(True)
        self.dispatcher._port_registry.has(2).AndReturn(False)
        self.dispatcher._create_module(app_config.modules[1], 2,
                                       None).AndReturn(self.module2)
        self.dispatcher._port_registry.has(2).AndReturn(True)
        self.dispatcher._port_registry.has(3).AndReturn(False)
        self.dispatcher._create_module(app_config.modules[2], 3,
                                       None).AndReturn(self.module3)
        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."""
    stub_util.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())
Exemplo n.º 3
0
def setup_stubs():
  """Setup the API stubs. This can only be done once."""
  stub_util.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())
Exemplo n.º 4
0
    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()
        stub_util.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['stringprop'] = 'value3'
        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, 12]
        datastore.Put(self.entity4)
Exemplo n.º 5
0
  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()
    stub_util.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['stringprop'] = 'value3'
    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, 12]
    datastore.Put(self.entity4)
Exemplo n.º 6
0
  def setUp(self):
    self.mox = mox.Mox()
    stub_util.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.mox.StubOutWithMock(self.dispatcher._port_registry, 'has')
    self.dispatcher._port_registry.has(1).AndReturn(False)
    self.dispatcher._create_module(app_config.modules[0], 1, None).AndReturn(
        self.module1)
    self.dispatcher._port_registry.has(1).AndReturn(True)
    self.dispatcher._port_registry.has(2).AndReturn(False)
    self.dispatcher._create_module(app_config.modules[1], 2, None).AndReturn(
        self.module2)
    self.dispatcher._port_registry.has(2).AndReturn(True)
    self.dispatcher._port_registry.has(3).AndReturn(False)
    self.dispatcher._create_module(app_config.modules[2], 3, None).AndReturn(
        self.module3)
    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')
Exemplo n.º 7
0
  def setUp(self):
    self.app_id = 'myapp'
    os.environ['APPLICATION_ID'] = self.app_id
    stub_util.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')
Exemplo n.º 8
0
 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()
   stub_util.setup_test_stubs(
       app_id=self.app_id,
       application_root=None,  # Needed to allow index updates.
       datastore_consistency=consistent_policy)
Exemplo n.º 9
0
  def setUp(self):
    self.app_id = 'myapp'
    os.environ['APPLICATION_ID'] = self.app_id
    stub_util.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')
Exemplo n.º 10
0
def main(argv):
    stub_util.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)
Exemplo n.º 11
0
 def setUp(self, datastore_consistency_probability=1.0):
   self.app_id = 'dev~myapp'
   # TODO(benkraft): Clean this environ setting up at end-of-test.
   # (Many of the devappserver tests don't do this, so it can't be that
   # important.)
   os.environ['APPLICATION_ID'] = self.app_id
   consistency_policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(
     probability=datastore_consistency_probability)
   stub_util.setup_test_stubs(
     app_id=self.app_id,
     datastore_consistency=consistency_policy,
   )
Exemplo n.º 12
0
    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()
        stub_util.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)
Exemplo n.º 13
0
  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()
    stub_util.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)