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


Python httpretty.POST属性代码示例

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


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

示例1: setup

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def setup(self):
        httpretty.enable()

        self.key = RSAKey(kid='testkey').load(os.path.join(FIXTURE_ROOT, 'testkey.pem'))
        def jwks(_request, _uri, headers):  # noqa: E306
            ks = KEYS()
            ks.add(self.key.serialize())
            return 200, headers, ks.dump_jwks()
        httpretty.register_uri(
            httpretty.GET, oidc_rp_settings.PROVIDER_JWKS_ENDPOINT, status=200, body=jwks)
        httpretty.register_uri(
            httpretty.POST, oidc_rp_settings.PROVIDER_TOKEN_ENDPOINT,
            body=json.dumps({
                'id_token': self.generate_jws(), 'access_token': 'accesstoken',
                'refresh_token': 'refreshtoken', }),
            content_type='text/json')
        httpretty.register_uri(
            httpretty.GET, oidc_rp_settings.PROVIDER_USERINFO_ENDPOINT,
            body=json.dumps({'sub': '1234', 'email': 'test@example.com', }),
            content_type='text/json')

        yield

        httpretty.disable() 
开发者ID:impak-finance,项目名称:django-oidc-rp,代码行数:26,代码来源:test_backends.py

示例2: test_can_process_userinfo_included_in_the_id_token_instead_of_calling_the_userinfo_endpoint

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_can_process_userinfo_included_in_the_id_token_instead_of_calling_the_userinfo_endpoint(
            self, rf):
        httpretty.register_uri(
            httpretty.POST, oidc_rp_settings.PROVIDER_TOKEN_ENDPOINT,
            body=json.dumps({
                'id_token': self.generate_jws(email='test1@example.com'),
                'access_token': 'accesstoken',
                'refresh_token': 'refreshtoken',
            }),
            content_type='text/json')
        request = rf.get('/oidc/cb/', {'state': 'state', 'code': 'authcode', })
        SessionMiddleware().process_request(request)
        request.session.save()
        backend = OIDCAuthBackend()
        user = backend.authenticate(request, 'nonce')
        assert user.email == 'test1@example.com'
        assert user.oidc_user.sub == '1234' 
开发者ID:impak-finance,项目名称:django-oidc-rp,代码行数:19,代码来源:test_backends.py

示例3: test_log_out_the_user_if_the_id_token_is_not_valid

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_log_out_the_user_if_the_id_token_is_not_valid(self, rf):
        request = rf.get('/oidc/cb/', {'state': 'state', 'code': 'authcode', })
        SessionMiddleware().process_request(request)
        request.session.save()
        backend = OIDCAuthBackend()
        user = backend.authenticate(request, 'nonce')
        request.session['oidc_auth_id_token_exp_timestamp'] = \
            (tz.now() - dt.timedelta(minutes=1)).timestamp()
        request.session['oidc_auth_refresh_token'] = 'this_is_a_refresh_token'
        auth.login(request, user)
        request.user = user

        httpretty.register_uri(
            httpretty.POST, oidc_rp_settings.PROVIDER_TOKEN_ENDPOINT,
            body=json.dumps({
                'id_token': 'badidtoken', 'access_token': 'accesstoken',
                'refresh_token': 'refreshtoken', }),
            content_type='text/json')

        middleware = OIDCRefreshIDTokenMiddleware(lambda r: 'OK')
        middleware(request)
        assert not request.user.is_authenticated 
开发者ID:impak-finance,项目名称:django-oidc-rp,代码行数:24,代码来源:test_middleware.py

示例4: configure_httpretty

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def configure_httpretty(sitedir):
    httpretty.enable()
    dir = Path(f"tests/test_sites/data/test_{sitedir}/")
    data_file = dir / 'data.json'

    data = None
    with open(data_file) as f:
        data = json.load(f)

    for obj in data:
        method = httpretty.POST
        if obj['method'] == 'GET':
            method = httpretty.GET
        with open(dir / obj['file']) as f:
            httpretty.register_uri(
                method,
                obj['url'],
                f.read(),
            ) 
开发者ID:vn-ki,项目名称:anime-downloader,代码行数:21,代码来源:site.py

示例5: test_send_key_with_file

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_send_key_with_file(self):
        driver = android_w3c_driver()
        # Should not send this file
        tmp_f = tempfile.NamedTemporaryFile()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/element/element_id/value')
        )

        try:
            element = MobileWebElement(driver, 'element_id', w3c=True)
            element.send_keys(tmp_f.name)
        finally:
            tmp_f.close()

        d = get_httpretty_request_body(httpretty.last_request())
        assert d['text'] == ''.join(d['value']) 
开发者ID:appium,项目名称:python-client,代码行数:19,代码来源:webelement_test.py

示例6: test_find_element_by_android_data_matcher

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_find_element_by_android_data_matcher(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/element'),
            body='{"value": {"element-6066-11e4-a52e-4f735466cecf": "element-id"}}'
        )
        el = driver.find_element_by_android_data_matcher(
            name='title', args=['title', 'Animation'], className='class name')

        d = get_httpretty_request_body(httpretty.last_request())
        assert d['using'] == '-android datamatcher'
        value_dict = json.loads(d['value'])
        assert value_dict['args'] == ['title', 'Animation']
        assert value_dict['name'] == 'title'
        assert value_dict['class'] == 'class name'
        assert el.id == 'element-id' 
开发者ID:appium,项目名称:python-client,代码行数:19,代码来源:android_test.py

示例7: test_find_elements_by_android_data_matcher

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_find_elements_by_android_data_matcher(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/elements'),
            body='{"value": [{"element-6066-11e4-a52e-4f735466cecf": "element-id1"}, {"element-6066-11e4-a52e-4f735466cecf": "element-id2"}]}'
        )
        els = driver.find_elements_by_android_data_matcher(name='title', args=['title', 'Animation'])

        d = get_httpretty_request_body(httpretty.last_request())
        assert d['using'] == '-android datamatcher'
        value_dict = json.loads(d['value'])
        assert value_dict['args'] == ['title', 'Animation']
        assert value_dict['name'] == 'title'
        assert els[0].id == 'element-id1'
        assert els[1].id == 'element-id2' 
开发者ID:appium,项目名称:python-client,代码行数:18,代码来源:android_test.py

示例8: because_an_event_is_published_on_a_stream

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def because_an_event_is_published_on_a_stream(self):
        httpretty.register_uri(
            httpretty.POST,
            "http://{}:{}/streams/{}".format(self._host, self._port, self.stream),
            body='{}')

        data = {'foo': 'bar'}
        metadata = {'lorem': 'ipsum'}
        evt = Event(
            id=self.event_id,
            type='my-event-type',
            data=data,
            stream=self.stream,
            sequence=None,
            metadata=metadata,
        )
        self.publisher.post(evt, correlation_id=self.correlation_id)
        self.response_body = json.loads(httpretty.last_request().body.decode())[0] 
开发者ID:madedotcom,项目名称:atomicpuppy,代码行数:20,代码来源:test_posting.py

示例9: test_cannot_authenticate_a_user_if_the_id_token_validation_fails

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_cannot_authenticate_a_user_if_the_id_token_validation_fails(self, rf):
        httpretty.register_uri(
            httpretty.POST, oidc_rp_settings.PROVIDER_TOKEN_ENDPOINT,
            body=json.dumps({
                'id_token': 'badidtoken', 'access_token': 'accesstoken',
                'refresh_token': 'refreshtoken', }),
            content_type='text/json')
        request = rf.get('/oidc/cb/', {'state': 'state', 'code': 'authcode', })
        SessionMiddleware().process_request(request)
        request.session.save()
        backend = OIDCAuthBackend()
        assert backend.authenticate(request, 'nonce') is None 
开发者ID:impak-finance,项目名称:django-oidc-rp,代码行数:14,代码来源:test_backends.py

示例10: test_request_timeout

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_request_timeout():
    timeout = 0.1
    http_scheme = "http"
    host = "coordinator"
    port = 8080
    url = http_scheme + "://" + host + ":" + str(port) + constants.URL_STATEMENT_PATH

    def long_call(request, uri, headers):
        time.sleep(timeout * 2)
        return (200, headers, "delayed success")

    httpretty.enable()
    for method in [httpretty.POST, httpretty.GET]:
        httpretty.register_uri(method, url, body=long_call)

    # timeout without retry
    for request_timeout in [timeout, (timeout, timeout)]:
        req = PrestoRequest(
            host=host,
            port=port,
            user="test",
            http_scheme=http_scheme,
            max_attempts=1,
            request_timeout=request_timeout,
        )

        with pytest.raises(requests.exceptions.Timeout):
            req.get(url)

        with pytest.raises(requests.exceptions.Timeout):
            req.post("select 1")

    httpretty.disable()
    httpretty.reset() 
开发者ID:prestosql,项目名称:presto-python-client,代码行数:36,代码来源:test_client.py

示例11: test_update_settings_bool

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_update_settings_bool(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/appium/settings'),
        )
        assert isinstance(driver.update_settings({"sample": True}), WebDriver)

        d = get_httpretty_request_body(httpretty.last_request())
        assert d['settings']['sample'] is True 
开发者ID:appium,项目名称:python-client,代码行数:12,代码来源:settings_test.py

示例12: test_update_settings_string

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_update_settings_string(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/appium/settings'),
        )
        assert isinstance(driver.update_settings({"sample": 'string'}), WebDriver)

        d = get_httpretty_request_body(httpretty.last_request())
        assert d['settings']['sample'] == 'string' 
开发者ID:appium,项目名称:python-client,代码行数:12,代码来源:settings_test.py

示例13: test_set_value

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_set_value(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/appium/element/element_id/value')
        )

        element = MobileWebElement(driver, 'element_id', w3c=True)
        value = 'happy testing'
        element.set_value(value)

        d = get_httpretty_request_body(httpretty.last_request())
        assert d['value'] == [value] 
开发者ID:appium,项目名称:python-client,代码行数:15,代码来源:webelement_test.py

示例14: test_send_key

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_send_key(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/element/element_id/value')
        )

        element = MobileWebElement(driver, 'element_id', w3c=True)
        element.send_keys('happy testing')

        d = get_httpretty_request_body(httpretty.last_request())
        assert d['text'] == ''.join(d['value']) 
开发者ID:appium,项目名称:python-client,代码行数:14,代码来源:webelement_test.py

示例15: test_press_keycode

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import POST [as 别名]
def test_press_keycode(self):
        driver = android_w3c_driver()
        httpretty.register_uri(
            httpretty.POST,
            appium_command('/session/1234567890/appium/device/press_keycode'),
            body='{"value": "86"}'
        )
        driver.press_keycode(86)
        d = get_httpretty_request_body((httpretty.last_request()))
        assert d['keycode'] == 86 
开发者ID:appium,项目名称:python-client,代码行数:12,代码来源:keyboard_test.py


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