Пример #1
0
 def setUp(self):
     s = LazySettings(
         settings_module='kay.tests.regressiontests.badurls_settings')
     self.app = get_application(settings=s)
     try:
         self.client = Client(self.app, BaseResponse)
     except DeadlineExceededError:
         pass
Пример #2
0
    def setUp(self):
        from google.appengine.api import memcache
        memcache.flush_all()
        s = LazySettings(settings_module='kay.tests.live_settings_settings')
        app = get_application(settings=s)
        self.client = Client(app, BaseResponse)

        live_settings.set("setting.1", "on")
        live_settings.set("setting.2", "off")
Пример #3
0
    def setUp(self):
        s = LazySettings(
            settings_module='kay.tests.regressiontests.server_error_settings')
        app = get_application(settings=s)
        self.client = Client(app, BaseResponse)
        self.client.test_logout()

        # Suppress logging error messages
        self._base_logger = logging.getLogger("")
        self._old_logging_handlers = self._base_logger.handlers
        self._base_logger.handlers = [NullHandler()]
Пример #4
0
 def setUp(self):
     try:
         self.original_user = os.environ['USER_EMAIL']
         self.original_is_admin = os.environ['USER_IS_ADMIN']
         del os.environ['USER_EMAIL']
         del os.environ['USER_IS_ADMIN']
     except Exception:
         pass
     s = LazySettings(settings_module='kay.tests.google_settings')
     app = get_application(settings=s)
     self.client = Client(app, BaseResponse)
     self.client.test_logout()
Пример #5
0
  def setUp(self):
    s = LazySettings(
      settings_module='kay.tests.ereporter_settings')
    app = get_application(settings=s)
    self.client = Client(app, BaseResponse)
    #self.client.test_logout()

    # Suppress logging error messages
    self._base_logger = logging.getLogger("")
    self._old_logging_handlers = self._base_logger.handlers
    self._base_logger.handlers = filter(
        lambda h: not isinstance(h, logging.StreamHandler),
        self._old_logging_handlers,
    ) 
Пример #6
0
def real_main():
    global application
    global applications
    server_name = os.environ.get('SERVER_NAME')
    target_setting = settings.PER_DOMAIN_SETTINGS.get(server_name, None)
    if target_setting:
        applications[server_name] = get_application(settings=LazySettings(
            settings_module=target_setting))
    if settings.DEBUG:
        logging.getLogger().setLevel(logging.DEBUG)
        if 'SERVER_SOFTWARE' in os.environ and \
              os.environ['SERVER_SOFTWARE'].startswith('Dev'):
            # use our debug.utils with Jinja2 templates
            import debug.utils
            sys.modules['werkzeug.debug.utils'] = debug.utils

            # don't use inspect.getsourcefile because the imp module is empty
            import inspect
            inspect.getsourcefile = inspect.getfile

            # wrap the application
            from werkzeug import DebuggedApplication
            global debugged_application
            global debugged_applications
            if target_setting:
                if not debugged_applications.has_key(server_name):
                    debugged_applications[server_name] = applications[server_name] = \
                        DebuggedApplication(applications[server_name], evalex=True)
                else:
                    applications[server_name] = debugged_applications[
                        server_name]
            else:
                if debugged_application is None:
                    debugged_application = application = DebuggedApplication(
                        application, evalex=True)
                else:
                    application = debugged_application
    else:
        logging.getLogger().setLevel(logging.INFO)
    if target_setting:
        KayHandler().run(applications[server_name])
    else:
        KayHandler().run(application)
Пример #7
0
    def setUp(self):
        apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
        stub = datastore_file_stub.DatastoreFileStub('test', '/dev/null',
                                                     '/dev/null')
        apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub)

        apiproxy_stub_map.apiproxy.RegisterStub(
            'user', user_service_stub.UserServiceStub())

        apiproxy_stub_map.apiproxy.RegisterStub(
            'memcache', memcache_stub.MemcacheServiceStub())

        apiproxy_stub_map.apiproxy.RegisterStub(
            'urlfetch', urlfetch_stub.URLFetchServiceStub())

        s = LazySettings(settings_module='kay.tests.settings')
        app = get_application(settings=s)
        self.client = Client(app, BaseResponse)
        if apiproxy_stub_map.apiproxy\
              ._APIProxyStubMap__stub_map.has_key('capability_service'):
            del(apiproxy_stub_map.apiproxy\
                  ._APIProxyStubMap__stub_map['capability_service'])
Пример #8
0
def do_preparse_apps():
    """
  Pre compile all the jinja2 templates in your applications.
  """
    from kay.conf import LazySettings
    print_status("Compiling templates...")
    application = kay.app.get_application()
    applications = [application]
    settings_treated = []
    for key, settings_name in \
          application.app.app_settings.PER_DOMAIN_SETTINGS.iteritems():
        if not settings_name in settings_treated:
            applications.append(
                kay.app.get_application(settings=LazySettings(
                    settings_module=settings_name)))
        settings_treated.append(settings_name)
    for app in applications:
        compile_app_templates(app.app)  # pass KayApp instance
        for key, submount_app in app.mounts.iteritems():
            if isinstance(submount_app, kay.app.KayApp):
                compile_app_templates(submount_app)

    print_status("Finished compiling templates...")
Пример #9
0
 def setUp(self):
   s = LazySettings(settings_module='kay.tests.settings')
   app = get_application(settings=s)
   self.client = Client(app, BaseResponse)
Пример #10
0
 def setUp(self):
   s = LazySettings(settings_module='kay.tests.settings')
   s.DEBUG = True
   app = get_application(settings=s)
   self.client = Client(app, BaseResponse)
Пример #11
0
 def setUp(self):
     s = LazySettings(settings_module='kay.tests.google_settings')
     self.app = get_application(settings=s)
Пример #12
0
 def setUp(self):
     from kay.auth import create_new_user
     s = LazySettings(settings_module='kay.tests.datastore_settings')
     app = get_application(settings=s)
     self.client = Client(app, BaseResponse)
     create_new_user("foobar", "password", is_admin=False)
Пример #13
0
 def setUp(self):
     s = LazySettings(settings_module='kay.tests.cache_test.settings')
     self.app = get_application(settings=s)
     self.client = Client(self.app, BaseResponse)
     memcache.flush_all()
Пример #14
0
 def setUp(self):
     from google.appengine.api import memcache
     memcache.flush_all()
     s = LazySettings(settings_module='kay.tests.appstats_settings')
     app = get_application(settings=s)
     self.client = Client(app, BaseResponse)
Пример #15
0
 def setUp(self):
     import os
     s = LazySettings(settings_module='kay.tests.cookie_session_settings')
     app = get_application(settings=s)
     self.client = Client(app, BaseResponse)
     self.server_name = os.environ['SERVER_NAME']