当前位置: 首页>>代码示例>>Python>>正文


Python Client.test_logout方法代码示例

本文整理汇总了Python中kay.utils.test.Client.test_logout方法的典型用法代码示例。如果您正苦于以下问题:Python Client.test_logout方法的具体用法?Python Client.test_logout怎么用?Python Client.test_logout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kay.utils.test.Client的用法示例。


在下文中一共展示了Client.test_logout方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ServerErrorTest

# 需要导入模块: from kay.utils.test import Client [as 别名]
# 或者: from kay.utils.test.Client import test_logout [as 别名]
class ServerErrorTest(GAETestBase):
    """
  Regression test for issue 54 that checks to make sure 
  that responses for error conditions extend BaseResponse.

  http://code.google.com/p/kay-framework/issues/detail?id=54
  """

    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()]

    def tearDown(self):
        self.client.test_logout()
        self._base_logger.handlers = self._old_logging_handlers

    def test_login(self):
        response = self.client.get(url_for("server_error_testapp/index"))
        self.assertEqual(response.status_code, 500)
        self.assertTrue(isinstance(response, BaseResponse))
开发者ID:nax589,项目名称:kay-framework,代码行数:29,代码来源:server_error_tests.py

示例2: DatastoreBackendTestCase

# 需要导入模块: from kay.utils.test import Client [as 别名]
# 或者: from kay.utils.test.Client import test_logout [as 别名]
class DatastoreBackendTestCase(GAETestBase):
  KIND_NAME_UNSWAPPED = False
  USE_PRODUCTION_STUBS = True
  CLEANUP_USED_KIND = True
  KIND_PREFIX_IN_TEST = 't2'
  
  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)

  def tearDown(self):
    self.client.test_logout()

  def test_login(self):
    response = self.client.get(url_for('auth_testapp/index'))
    self.assertEqual(response.status_code, 200)
    response = self.client.get(url_for('auth_testapp/secret'))
    self.assertEqual(response.status_code, 302)
    self.assert_(response.headers.get('Location').endswith(
        '/auth/login?next=http%253A%252F%252Flocalhost%252Fsecret'))

    self.client.test_login(username='foobar')
    response = self.client.get(url_for('auth_testapp/secret'))
    self.assertEqual(response.status_code, 200)
    self.client.test_logout()
    response = self.client.get(url_for('auth_testapp/secret'))
    self.assertEqual(response.status_code, 302)
开发者ID:IanLewis,项目名称:kay,代码行数:32,代码来源:auth_test.py

示例3: EReporterTest

# 需要导入模块: from kay.utils.test import Client [as 别名]
# 或者: from kay.utils.test.Client import test_logout [as 别名]
class EReporterTest(GAETestBase):
  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,
    ) 

  def tearDown(self):
    self.client.test_logout()
    self._base_logger.handlers = self._old_logging_handlers

  def test_ereporter(self):
    from kay.ext.ereporter.models import ExceptionRecord
    self.assertEqual(ExceptionRecord.all().count(), 0, "ExceptionRecord objects already exist!")

    response = self.client.get(url_for('ereporter_testapp/index'))
    self.assertEqual(response.status_code, 500, "Expected 500 error code.")
    self.assertEqual(ExceptionRecord.all().count(), 1)

    # Simulate the key expiring.
    memcache.flush_all();

    response = self.client.get(url_for('ereporter_testapp/index'))
    self.assertEqual(response.status_code, 500, "Expected 500 error code.")
    self.assertEqual(ExceptionRecord.all().count(), 1, "More than one ExceptionRecord object was created!")
    self.assertEqual(ExceptionRecord.all()[0].count, 2, "ExceptionRecord count not incremented!")
开发者ID:dbordak,项目名称:pyblog,代码行数:37,代码来源:ereporter_test.py

示例4: RestTestCase

# 需要导入模块: from kay.utils.test import Client [as 别名]
# 或者: from kay.utils.test.Client import test_logout [as 别名]
class RestTestCase(GAETestBase):
  KIND_NAME_UNSWAPPED = False
  USE_PRODUCTION_STUBS = True
  CLEANUP_USED_KIND = True
  KIND_PREFIX_IN_TEST = "t2"

  def setUp(self):
    s = LazySettings(settings_module='kay.tests.rest_settings')
    app = get_application(settings=s)
    self.client = Client(app, BaseResponse)
    self.client.test_logout()

  def tearDown(self):
    self.client.test_logout()

  def test_rest_operations(self):
    self.client.test_login(email="[email protected]", is_admin="1")
    response = self.client.get('/rest/metadata')
    self.assertEqual(response.status_code, 200)

    response = self.client.get('/rest/metadata/RestModel')
    self.assertEqual(response.status_code, 200)

    response = self.client.post('/rest/RestModel', data='<?xml version="1.0" encoding="utf-8"?><RestModel><i_prop>12</i_prop><s_prop>string</s_prop></RestModel>')
    self.assertEqual(response.status_code, 200)
    key = response.data
    elm = RestModel.get(key)
    self.assertEqual(elm.s_prop, "string")
    self.assertEqual(elm.i_prop, 12)

    response = self.client.post(
      '/rest/RestModel/%s' % key,
      data='<?xml version="1.0" encoding="utf-8"?><RestModel><i_prop>14</i_prop></RestModel>')
    self.assertEqual(response.status_code, 200)
    key2 = response.data
    self.assertEqual(key, key2)
    elm = RestModel.get(key)
    self.assertEqual(elm.s_prop, "string")
    self.assertEqual(elm.i_prop, 14)

    response = self.client.get('/rest/RestModel')
    self.assertEqual(response.status_code, 200)

    response = self.client.get('/rest/RestModel/%s' % key)
    self.assertEqual(response.status_code, 200)

    response = self.client.get('/rest/RestModel/%s/s_prop' % key)
    self.assertEqual(response.status_code, 200)
    self.assertEqual(response.data, "string")

    response = self.client.get('/rest/RestModel/%s/i_prop' % key)
    self.assertEqual(response.status_code, 200)
    self.assertEqual(response.data, "14")

    response = self.client.delete('/rest/RestModel/%s' % key)
    self.assertEqual(response.status_code, 200)

    response = self.client.get('/rest/RestModel/%s' % key)
    self.assertEqual(response.status_code, 404)
开发者ID:IanLewis,项目名称:kay,代码行数:61,代码来源:rest_test.py

示例5: DatastoreBackendTestCase

# 需要导入模块: from kay.utils.test import Client [as 别名]
# 或者: from kay.utils.test.Client import test_logout [as 别名]
class DatastoreBackendTestCase(GAETestBase):
  KIND_NAME_UNSWAPPED = False
  USE_PRODUCTION_STUBS = True
  CLEANUP_USED_KIND = True
  KIND_PREFIX_IN_TEST = 't2'
  
  def setUp(self):
    s = LazySettings(settings_module='kay.tests.datastore_settings')
    app = get_application(settings=s)
    self.client = Client(app, BaseResponse)

  def tearDown(self):
    self.client.test_logout()

  def test_login(self):
    from kay.auth import create_new_user
    create_new_user("foobar", "password", is_admin=False)
    response = self.client.get(url_for('auth_testapp/index'))
    self.assertEqual(response.status_code, 200)
    response = self.client.get(url_for('auth_testapp/secret'))
    self.assertEqual(response.status_code, 302)
    self.assert_(response.headers.get('Location').endswith(
        '/auth/login?next=http%253A%252F%252Flocalhost%252Fsecret'))

    self.client.test_login(username='foobar')
    response = self.client.get(url_for('auth_testapp/secret'))
    self.assertEqual(response.status_code, 200)
    self.client.test_logout()
    response = self.client.get(url_for('auth_testapp/secret'))
    self.assertEqual(response.status_code, 302)

  def test_create_inactive_user(self):
      from kay.auth.models import DatastoreUser
      from kay.utils import crypto

      user = DatastoreUser.create_inactive_user("testuser", "password",
                                                "[email protected]",
                                                do_registration=False) 
      self.assertEqual(user.key().name(),
                       DatastoreUser.get_key_name("testuser"))
      self.assertEqual(user.user_name, "testuser")
    
      self.assertTrue(crypto.check_pwhash(user.password, "password"))
      self.assertEqual(user.email, "[email protected]")
开发者ID:gmist,项目名称:kay-ru,代码行数:46,代码来源:auth_test.py

示例6: GAEMABackendTestCase

# 需要导入模块: from kay.utils.test import Client [as 别名]
# 或者: from kay.utils.test.Client import test_logout [as 别名]
class GAEMABackendTestCase(GAETestBase):
  KIND_NAME_UNSWAPPED = False
  USE_PRODUCTION_STUBS = True
  CLEANUP_USED_KIND = True
  KIND_PREFIX_IN_TEST = 't3'

  def setUp(self):
    s = LazySettings(settings_module='kay.tests.gaema_settings')
    app = get_application(settings=s)
    self.client = Client(app, BaseResponse)

  def tearDown(self):
    self.client.test_logout(service='shehas.net')

  def test_login(self):
    response = self.client.get(url_for('gaema_testapp/index'))
    self.assertEqual(response.status_code, 200)
    response = self.client.get(url_for('gaema_testapp/secret',
                                       domain_name='shehas.net'))
    self.assertEqual(response.status_code, 302)
    self.assert_(response.headers.get('Location').endswith(
        '/_ah/gaema/marketplace_login/a/shehas.net'))

    self.client.test_login(service='shehas.net',
                           user_data={'claimed_id': 'http://shehas.net/123',
                                      'email': '[email protected]'})

    response = self.client.get(url_for('gaema_testapp/secret',
                                       domain_name='shehas.net'))
    self.assertEqual(response.status_code, 200)

    response = self.client.get(url_for('gaema_testapp/secret',
                                       domain_name='example.com'))
    self.assertEqual(response.status_code, 302)
    self.assert_(response.headers.get('Location').endswith(
        '/_ah/gaema/marketplace_login/a/example.com'))

    self.client.test_logout(service='shehas.net')

    response = self.client.get(url_for('gaema_testapp/secret',
                                       domain_name='shehas.net'))
    self.assertEqual(response.status_code, 302)
开发者ID:IanLewis,项目名称:kay,代码行数:44,代码来源:auth_test.py

示例7: ServerErrorTest

# 需要导入模块: from kay.utils.test import Client [as 别名]
# 或者: from kay.utils.test.Client import test_logout [as 别名]
class ServerErrorTest(GAETestBase):
  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()] 

  def tearDown(self):
    self.client.test_logout()
    self._base_logger.handlers = self._old_logging_handlers

  def test_login(self):
    response = self.client.get(url_for('server_error_testapp/index'))
    self.assertEqual(response.status_code, 500)
    self.assertTrue(isinstance(response, BaseResponse))
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:23,代码来源:server_error_tests.py

示例8: GoogleBackendTestCase

# 需要导入模块: from kay.utils.test import Client [as 别名]
# 或者: from kay.utils.test.Client import test_logout [as 别名]
class GoogleBackendTestCase(GAETestBase):
  KIND_NAME_UNSWAPPED = False
  USE_PRODUCTION_STUBS = True
  CLEANUP_USED_KIND = True
  KIND_PREFIX_IN_TEST = 't1'
  
  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()

  def tearDown(self):
    self.client.test_logout()

  def test_login(self):
    response = self.client.get(url_for('auth_testapp/index'))
    self.assertEqual(response.status_code, 200)
    response = self.client.get(url_for('auth_testapp/secret'))
    self.assertEqual(response.status_code, 302)
    self.client.test_login(email="[email protected]", is_admin="1")
    response = self.client.get(url_for('auth_testapp/secret'))
    self.assertEqual(response.status_code, 200)
    self.client.test_logout()
    response = self.client.get(url_for('auth_testapp/secret'))
    self.assertEqual(response.status_code, 302)
开发者ID:IanLewis,项目名称:kay,代码行数:35,代码来源:auth_test.py

示例9: CacheTestCase

# 需要导入模块: from kay.utils.test import Client [as 别名]
# 或者: from kay.utils.test.Client import test_logout [as 别名]
class CacheTestCase(GAETestBase):
  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()
    
  def test_cache_middleware(self):
    # make sure that CACHE_MIDDLEWARE_ANONYMOUSE_ONLY works
    self.client.test_login(email='[email protected]')
    response = self.client.get(url_for('cache_testapp/index'))
    self.assertEqual(response.status_code, 200)
    c = memcache.get('http://localhost/?lang=en', namespace='CACHE_MIDDLEWARE')
    self.assertEqual(c, None)
    self.client.test_logout()
    # user logout, so the cache works
    response = self.client.get(url_for('cache_testapp/index'))
    self.assertEqual(response.status_code, 200)
    c = memcache.get('http://localhost/?lang=en', namespace='CACHE_MIDDLEWARE')
    self.assertEqual(c.data, response.data)

  def test_cache_decorator_with_function_view(self):
    # make sure that CACHE_MIDDLEWARE_ANONYMOUSE_ONLY works
    self.client.test_login(email='[email protected]')
    response = self.client.get(url_for('cache_testapp/decorator'))
    self.assertEqual(response.status_code, 200)
    c = memcache.get('http://localhost/decorator?lang=en',
                     namespace='CACHE_DECORATOR')
    self.assertEqual(c, None)
    self.client.test_logout()
    # user logout, so the cache works
    response = self.client.get(url_for('cache_testapp/decorator'))
    self.assertEqual(response.status_code, 200)
    c = memcache.get('http://localhost/decorator?lang=en',
                     namespace='CACHE_DECORATOR')
    self.assertEqual(c.data, response.data)

  def test_cache_decorator_with_class_view(self):
    # make sure that CACHE_MIDDLEWARE_ANONYMOUSE_ONLY works
    self.client.test_login(email='[email protected]')
    response = self.client.get(url_for('cache_testapp/decorator_class'))
    self.assertEqual(response.status_code, 200)
    c = memcache.get('http://localhost/decorator_class?lang=en',
                     namespace='CACHE_DECORATOR')
    self.assertEqual(c, None)
    self.client.test_logout()
    # user logout, so the cache works
    response = self.client.get(url_for('cache_testapp/decorator_class'))
    self.assertEqual(response.status_code, 200)
    c = memcache.get('http://localhost/decorator_class?lang=en',
                     namespace='CACHE_DECORATOR')
    self.assertEqual(c.data, response.data)
开发者ID:dbordak,项目名称:pyblog,代码行数:54,代码来源:tests.py

示例10: RestJSONTestCase

# 需要导入模块: from kay.utils.test import Client [as 别名]
# 或者: from kay.utils.test.Client import test_logout [as 别名]
class RestJSONTestCase(GAETestBase):
  KIND_NAME_UNSWAPPED = False
  USE_PRODUCTION_STUBS = True
  CLEANUP_USED_KIND = True

  def setUp(self):
    s = LazySettings(settings_module='kay.tests.rest_settings')
    app = get_application(settings=s)
    self.client = Client(app, BaseResponse)
    self.client.test_logout()

  def tearDown(self):
    self.client.test_logout()

  def test_rest_json(self):

    headers = Headers({"Accept": "application/json"})

    response = self.client.get('/rest/metadata', headers=headers)
    self.assertEqual(response.status_code, 403)

    self.client.test_login(email="[email protected]")
    response = self.client.get('/rest/metadata', headers=headers)
    self.assertEqual(response.status_code, 403)

    self.client.test_login(email="[email protected]", is_admin="1")
    response = self.client.get('/rest/metadata', headers=headers)
    self.assertEqual(response.status_code, 200)

    self.client.test_logout()
    response = self.client.get('/rest/metadata/RestModel', headers=headers)
    self.assertEqual(response.status_code, 403)

    self.client.test_login(email="[email protected]")
    response = self.client.get('/rest/metadata/RestModel', headers=headers)
    self.assertEqual(response.status_code, 403)

    self.client.test_login(email="[email protected]", is_admin="1")
    response = self.client.get('/rest/metadata/RestModel', headers=headers)
    self.assertEqual(response.status_code, 200)


    self.client.test_logout()
    response = self.client.post(
      '/rest/RestModel',
      data='{"RestModel": {"i_prop": 12, "s_prop": "string"}}',
      content_type="application/json; charset=utf-8")
    self.assertEqual(response.status_code, 403)

    self.client.test_login(email="[email protected]")
    response = self.client.post(
      '/rest/RestModel',
      data='{"RestModel": {"i_prop": 12, "s_prop": "string"}}',
      content_type="application/json; charset=utf-8")
    self.assertEqual(response.status_code, 403)

    self.client.test_login(email="[email protected]", is_admin="1")
    response = self.client.post(
      '/rest/RestModel',
      data='{"RestModel": {"i_prop": 12, "s_prop": "string"}}',
      content_type="application/json; charset=utf-8")
    self.assertEqual(response.status_code, 200)

    key = response.data
    elm = RestModel.get(key)
    self.assertEqual(elm.s_prop, "string")
    self.assertEqual(elm.i_prop, 12)

    self.client.test_logout()
    response = self.client.post(
      '/rest/RestModel/%s' % key,
      data='{"RestModel": {"i_prop": 14}}',
      content_type="application/json; charset=utf-8")
    self.assertEqual(response.status_code, 403)

    self.client.test_login(email="[email protected]")
    response = self.client.post(
      '/rest/RestModel/%s' % key,
      data='{"RestModel": {"i_prop": 14}}',
      content_type="application/json; charset=utf-8")
    self.assertEqual(response.status_code, 403)

    self.client.test_login(email="[email protected]", is_admin="1")
    response = self.client.post(
      '/rest/RestModel/%s' % key,
      data='{"RestModel": {"i_prop": 14}}',
      content_type="application/json; charset=utf-8")
    self.assertEqual(response.status_code, 200)

    key2 = response.data
    self.assertEqual(key, key2)
    elm = RestModel.get(key)
    self.assertEqual(elm.s_prop, "string")
    self.assertEqual(elm.i_prop, 14)
    
    response = self.client.post(
      '/rest/RestModel',
      data='[{"RestModel": {"i_prop": 1, "s_prop": "foobar1"}},{"RestModel": {"i_prop": 2, "s_prop": "foobar2"}}]',
      content_type="application/json; charset=utf-8")
    self.assertEqual(response.status_code, 200)
#.........这里部分代码省略.........
开发者ID:dbordak,项目名称:pyblog,代码行数:103,代码来源:rest_test.py

示例11: TsuhanTest

# 需要导入模块: from kay.utils.test import Client [as 别名]
# 或者: from kay.utils.test.Client import test_logout [as 别名]
class TsuhanTest(GAETestBase):
    CLEANUP_USED_KIND = False
    USE_PRODUCTION_STUBS = True
    KIND_NAME_UNSWAPPED=False
    USE_REMOTE_STUBS=False

    def setUp(self):
        init_recording()
        app = get_application()
        self.client = Client(app, BaseResponse)
        self.client.test_login()

    def tearDown(self):
        self.client.test_logout()
        disable_recording()

    def test_index(self):
        response = self.client.open(
            path=url_for('core/index'),
            method='GET',
            data=dict(),
        )
        self.assertEqual(response.status_code, 200)

    def test_products(self):
        response = self.client.open(
            path=url_for('core/products',category_code='01',list_per_page=20,page_index=0),
            method='GET',
            data=dict(),
        )
        self.assertEqual(response.status_code, 200)

    def test_tags(self):
        response = self.client.open(
            path=url_for('core/tags',tags=u'タグ',list_per_page=20,page_index=0),
            method='GET',
            data=dict(),
        )
        self.assertEqual(response.status_code, 200)

    def test_search(self):
        response = self.client.open(
            path=url_for('core/search',words=u'検索ワード',list_per_page=20,page_index=0),
            method='GET',
            data=dict(),
        )
        self.assertEqual(response.status_code, 200)

    def test_detail(self):
        response = self.client.open(
            path=url_for('core/detail',article_id='421135'),
            method='GET',
            data=dict(),
        )
        self.assertEqual(response.status_code, 200)

    def test_sitemap(self):
        response = self.client.open(
            path=url_for('core/sitemap'),
            method='GET',
            data=dict(),
        )
        self.assertEqual(response.status_code, 404)
开发者ID:cedarjp,项目名称:tsuhan-be,代码行数:65,代码来源:__init__.py


注:本文中的kay.utils.test.Client.test_logout方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。