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


Python Client.get方法代码示例

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


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

示例1: TestWSLoader

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class TestWSLoader(unittest.TestCase):
    def setUp(self):
        app = wsloader.WSLoader(confdir = os.getcwd() + '/conf/')
        self.client = Client(app, BaseResponse)

    def test_service_check(self):
        response = self.client.get("/greeter/service_check")
        print response.data
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.data, "OK")

    def test_defaults(self):
        response = self.client.get("/greeter/say_hello")
        self.assertEqual(response.status_code, 200)
        body = json.loads(response.data)
        self.assertEqual(body['response'], "Hello World!")

    def test_aliased_class(self):
        response = self.client.get('/helloworld/say_hello?greeting="Hola"&to_whom="Amigos!"')
        try:
            body = json.loads(response.data)
        except Exception, e:
            print e
            print response.data
            return
        self.assertEqual(body['response'], "Hola Amigos!")
开发者ID:codemartial,项目名称:wsloader,代码行数:28,代码来源:test.py

示例2: TestSession

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class TestSession(unittest.TestCase):

    def setUp(self):
        self.app = make_wsgi('Testruns')
        self.client = Client(self.app, BaseResponse)

    def tearDown(self):
        self.client = None
        self.app = None

    def test_session_persist(self):
        r = self.client.get('/sessiontests/setfoo')

        self.assertEqual(r.status, '200 OK')
        self.assertEqual(r.data, b'foo set')

        r = self.client.get('/sessiontests/getfoo')

        self.assertEqual(r.status, '200 OK')
        self.assertEqual(r.data, b'bar')

    def test_session_regen_id(self):
        ta = TestApp(self.app)

        r = ta.get('/sessiontests/setfoo', status=200)
        assert r.session['foo'] == 'bar'
        sid = r.session.id
        assert sid in r.headers['Set-Cookie']

        r = ta.get('/sessiontests/regenid', status=200)
        assert r.session.id != sid
        assert r.session.id in r.headers['Set-Cookie']

        r = ta.get('/sessiontests/getfoo', status=200)
        assert r.body == b'bar'
开发者ID:level12,项目名称:blazeweb,代码行数:37,代码来源:test_session.py

示例3: SessionMiddlewareTestCase

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class SessionMiddlewareTestCase(GAETestBase):
  KIND_NAME_UNSWAPPED = False
  USE_PRODUCTION_STUBS = True
  CLEANUP_USED_KIND = True

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

  def tearDown(self):
    pass

  def test_countup(self):
    response = self.client.get('/countup')
    self.assertEqual(response.status_code, 200)
    self.assertEqual(response.data, '1')
    response = self.client.get('/countup')
    self.assertEqual(response.data, '2')
    response = self.client.get('/countup')
    self.assertEqual(response.data, '3')
    response = self.client.get('/countup')
    self.assertEqual(response.data, '4')
    response = self.client.get('/countup')
    self.assertEqual(response.data, '5')
开发者ID:IanLewis,项目名称:kay,代码行数:27,代码来源:session_test.py

示例4: TasksViewTest

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class TasksViewTest(unittest.TestCase):

    def setUp(self):
        self.c = Client(views.handler, BaseResponse)
        # clear state
        views.TASKS = {}
        views.clients = {}
        views.subscriptions = {}

    def test_POST(self):
        t = models.Task(name='Task1')
        r = self.c.post(path='/tasks/', headers={'Content-Type':tubes.JSON}, data=t.to_json_str())

        # check response
        self.assertEquals(r.status_code, 201)
        task = json.loads(r.data)
        self.assertEquals(task['name'], 'Task1')
        self.assertTrue('/tasks/0' in r.headers.get('Location'))

        # back-end
        task = views.TASKS['0']
        self.assertTrue(task != None)
        self.assertEquals(task.name, 'Task1')

    def test_PUT(self):
        views.TASKS['0'] = models.Task()
        r = self.c.put(path='/tasks/0',
                       headers={'Content-Type':tubes.JSON},
                       data=models.Task(name='Task_0').to_json_str())
        self.assertEquals(r.status_code, 200)

        # check response
        task = json.loads(r.data)
        self.assertEquals(task['name'], 'Task_0')

        # back-end
        task = views.TASKS['0']
        self.assertEquals(task.name, 'Task_0')

    def test_DELETE(self):
        views.TASKS['0'] = models.Task()
        r = self.c.delete(path='/tasks/0')
        self.assertEquals(r.status_code, 204)
        self.assertTrue(views.TASKS.get('0') == None)

    def test_GET_tasks(self):
        views.TASKS['0'] = models.Task(name='foo')
        r = self.c.get(path='/tasks/')
        self.assertTrue('foo' in r.data)

    def test_GET_task(self):
        views.TASKS['0'] = models.Task(name='foo')
        r = self.c.get(path='/tasks/0')
        self.assertTrue('foo' in r.data)
开发者ID:jakobadam,项目名称:letsplantheevent,代码行数:56,代码来源:tests.py

示例5: MaintenanceCheckTestCase

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class MaintenanceCheckTestCase(unittest.TestCase):
  
  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'])

  def tearDown(self):
    pass

  def test_success(self):
    """Test with normal CapabilityServiceStub"""
    apiproxy_stub_map.apiproxy.RegisterStub(
      'capability_service',
      capability_stub.CapabilityServiceStub())
    response = self.client.get('/')
    self.assertEqual(response.status_code, 200)

  def test_failure(self):
    """Test with DisabledCapabilityServiceStub
    """
    apiproxy_stub_map.apiproxy.RegisterStub(
      'capability_service',
      mocked_capability_stub.DisabledCapabilityServiceStub())
    response = self.client.get('/')
    self.assertEqual(response.status_code, 302)
    self.assertEqual(response.headers['Location'],
                     'http://localhost/maintenance_page')

    response = self.client.get('/index2')
    self.assertEqual(response.status_code, 302)
    self.assertEqual(response.headers['Location'],
                     'http://localhost/no_decorator')
    response = self.client.get('/no_decorator')
    self.assertEqual(response.status_code, 200)
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:55,代码来源:decorator_test.py

示例6: DownloadicsTest

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class DownloadicsTest(GAETestBase):

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

        self.test_values = {
            'date': datetime.datetime(2016, 5, 20, 15, 0),
            'title': 'THIS IS TITLE',
            'description': 'THIS IS TITLE',
        }

        eve = Event(
            event_date=self.test_values['date'],
            title=self.test_values['title'],
            description=self.test_values['description'],
        )
        eve.put()
        events = Event.all().fetch(100)
        self.assertEquals(len(events), 1)
        self.assertEquals(events[0].title, 'THIS IS TITLE')
        self.event_key = str(events[0].key())

    def test_download_individual_icsfile(self):
        target_url = urlparse.urljoin('/ical/', self.event_key)
        res = self.client.get(target_url)
        self.assertEquals(res.status_code, 200)

        downloaded = res.get_data()
        reparsed = icalendar.Calendar.from_ical(downloaded)
        reparsed_eve = reparsed.walk('VEVENT')[0]
        stringfied = self.test_values['date'].strftime('%Y%m%dT%H%M%S')
        self.assertEquals(reparsed_eve['summary'].to_ical(), self.test_values['title'])
        self.assertEquals(reparsed_eve['dtstart'].to_ical(), stringfied)
        self.assertEquals(reparsed_eve['description'].to_ical(), self.test_values['description'])
开发者ID:yosukesuzuki,项目名称:calendar-app,代码行数:37,代码来源:test_views.py

示例7: CronOnlyTestCase

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class CronOnlyTestCase(GAETestBase):

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

  def test_cron_only(self):
    response = self.client.get("/cron",
            headers=(('X-AppEngine-Cron', 'true'),))
    self.assertEqual(response.status_code, 200)
    self.assertTrue(response.data == "OK")

  def test_cron_only_failure(self):
    response = self.client.get("/cron")
    self.assertEqual(response.status_code, 403)
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:18,代码来源:decorator_test.py

示例8: AppStatsMiddlewareTestCase

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class AppStatsMiddlewareTestCase(GAETestBase):
  KIND_NAME_UNSWAPPED = False
  USE_PRODUCTION_STUBS = True
  CLEANUP_USED_KIND = True

  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)

  def tearDown(self):
    pass

  def test_appstats_middleware(self):

    request = Request({})
    middleware = AppStatsMiddleware()

    r = middleware.process_request(request)
    self.assertTrue(r is None)

    r = middleware.process_response(request, BaseResponse("", 200))
    self.assertTrue(isinstance(r, BaseResponse))

    summary = recording.load_summary_protos()
    self.assert_(summary)

  def test_appstats_middleware_request(self):

    response = self.client.get('/no_decorator')
    summary = recording.load_summary_protos()
    self.assert_(summary)
开发者ID:dbordak,项目名称:pyblog,代码行数:36,代码来源:appstats_test.py

示例9: test_responder

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
def test_responder():
    """Responder decorator"""
    def foo(environ, start_response):
        return BaseResponse('Test')
    client = Client(responder(foo), BaseResponse)
    response = client.get('/')
    assert response.status_code == 200
    assert response.data == 'Test'
开发者ID:marchon,项目名称:checkinmapper,代码行数:10,代码来源:test_wsgi.py

示例10: MaintenanceCheckTestCase

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class MaintenanceCheckTestCase(unittest.TestCase):
    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"])

    def tearDown(self):
        pass

    def test_success(self):
        """Test with normal CapabilityServiceStub"""
        apiproxy_stub_map.apiproxy.RegisterStub("capability_service", capability_stub.CapabilityServiceStub())
        response = self.client.get("/")
        self.assertEqual(response.status_code, 200)

    def test_failure(self):
        """Test with DisabledCapabilityServiceStub
    """
        apiproxy_stub_map.apiproxy.RegisterStub(
            "capability_service", mocked_capability_stub.DisabledCapabilityServiceStub()
        )
        response = self.client.get("/")
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response.headers["Location"], "http://localhost/maintenance_page")

        response = self.client.get("/index2")
        self.assertEqual(response.status_code, 302)
        self.assertEqual(response.headers["Location"], "http://localhost/no_decorator")
        response = self.client.get("/no_decorator")
        self.assertEqual(response.status_code, 200)
开发者ID:soha,项目名称:BooksGoten,代码行数:44,代码来源:decorator_test.py

示例11: CronOnlyDebugTestCase

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class CronOnlyDebugTestCase(GAETestBase):

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

  def test_cron_only_failure(self):
    from kay.utils import is_dev_server
    response = self.client.get("/cron")
    if is_dev_server():
      self.assertEqual(response.status_code, 200)
    else:
      self.assertEqual(response.status_code, 403)

  def test_cron_only(self):
    response = self.client.get("/cron",
            headers=(('X-AppEngine-Cron', 'true'),))
    self.assertEqual(response.status_code, 200)
    self.assertTrue(response.data == "OK")
开发者ID:gdgkyoto,项目名称:kyoto-gtug,代码行数:23,代码来源:decorator_test.py

示例12: test_View_index

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class test_View_index(GAETestBase):
  CLEANUP_USED_KIND = True
  USE_PRODUCTION_STUBS = True

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

  def tearDown(self):
    disable_recording()

  def test_base(self):
    response = self.client.get('/')
    self.assertEquals(response.status_code, 404)

  def test_client_get(self):
    response = self.client.get('/client')
    self.assertEquals(response.status_code, 301)

  def test_client_head(self):
    self.fail('test_View_index.test_client_head not yet written')

  def test_client_post(self):
    self.fail('test_View_index.test_client_post not yet written')

  def test_client_put(self):
    self.fail('test_View_index.test_client_put not yet written')

  def test_client_delete(self):
    self.fail('test_View_index.test_client_delete not yet written')

  def test_client_options(self):
    self.fail('test_View_index.test_client_options not yet written')

  def test_client_trace(self):
    self.fail('test_View_index.test_client_trace not yet written')

  def test_client_connect(self):
    self.fail('test_View_index.test_client_connect not yet written')
开发者ID:sagallagherstarr,项目名称:OPURL-SERVER,代码行数:42,代码来源:Test_View_index.py

示例13: wrapper

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
 def wrapper(self):
     client = Client(Application(), BaseResponse)
     response = client.get(url, headers={'Accept': accept})
     eq_(response.status_code, status_code)
     if template:
         assert response.template ==template
     f(self, response, response.context, PyQuery(response.data))
     # Validate after other tests so we know everything else works.
     # Hacky piggybacking on --verbose so tests go faster.
     if '--verbose' in sys.argv:
         validator = post_multipart('validator.w3.org', '/check',
                                    {'fragment': response.data})
         assert PyQuery(validator)('#congrats').size() == 1
开发者ID:jbalogh,项目名称:bosley,代码行数:15,代码来源:test_views.py

示例14: MaintenanceCheckTestCase

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class MaintenanceCheckTestCase(unittest.TestCase):

  def setUp(self):
    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'])

  def tearDown(self):
    pass

  def test_success(self):
    """Test with normal CapabilityServiceStub"""
    apiproxy_stub_map.apiproxy.RegisterStub(
      'capability_service',
      capability_stub.CapabilityServiceStub())
    response = self.client.get('/')
    self.assertEqual(response.status_code, 200)

  def test_failure(self):
    """Test with DisabledCapabilityServiceStub
    """
    apiproxy_stub_map.apiproxy.RegisterStub(
      'capability_service',
      mocked_capability_stub.DisabledCapabilityServiceStub())
    response = self.client.get('/')
    self.assertEqual(response.status_code, 302)
    self.assertEqual(response.headers['Location'],
                     'http://localhost/_kay/maintenance_page')

    response = self.client.get('/index2')
    self.assertEqual(response.status_code, 302)
    self.assertEqual(response.headers['Location'],
                     'http://localhost/no_decorator')
    response = self.client.get('/no_decorator')
    self.assertEqual(response.status_code, 200)
开发者ID:bguided,项目名称:synctester,代码行数:41,代码来源:decorator_test.py

示例15: MaintenanceCheckTestCase

# 需要导入模块: from werkzeug import Client [as 别名]
# 或者: from werkzeug.Client import get [as 别名]
class MaintenanceCheckTestCase(unittest.TestCase):

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

  def tearDown(self):
    pass

  def test_redirect(self):
    """Test with normal CapabilityServiceStub"""
    response = self.client.get('/oldpage', follow_redirects=True)
    self.assertEqual(response.status_code, 200)
    self.assertEqual(response.data, "New")
开发者ID:bguided,项目名称:synctester,代码行数:17,代码来源:redirect.py


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