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


Python responses.PUT属性代码示例

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


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

示例1: test_put

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_put(patch1, patch2):
    """
    Test put functionality
    """
    responses.add(
        responses.PUT,
        'http://promhost:80/api/v1.0/node-label/n1',
        body='{"key1":"label1"}',
        status=200)

    prom_session = PromenadeSession()
    result = prom_session.put(
        'v1.0/node-label/n1', body='{"key1":"label1"}', timeout=(60, 60))

    assert PROM_HOST == prom_session.host
    assert result.status_code == 200 
开发者ID:airshipit,项目名称:drydock,代码行数:18,代码来源:test_k8sdriver_promenade_client.py

示例2: test_relabel_node

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_relabel_node(patch1, patch2):
    """
    Test relabel node call from Promenade
    Client
    """
    responses.add(
        responses.PUT,
        'http://promhost:80/api/v1.0/node-labels/n1',
        body='{"key1":"label1"}',
        status=200)

    prom_client = PromenadeClient()

    result = prom_client.relabel_node('n1', {"key1": "label1"})

    assert result == {"key1": "label1"} 
开发者ID:airshipit,项目名称:drydock,代码行数:18,代码来源:test_k8sdriver_promenade_client.py

示例3: test_add_item

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_add_item():
    collection_id = "abcd"
    responses.add(
        responses.PUT,
        "{}collections/{}/items".format(BASE_URL, collection_id),
        body=json.dumps(example_item),
        status=200,
        content_type="application/json",
    )

    client = TwitchClient("client id", "oauth client")

    item = client.collections.add_item(collection_id, "1234", "video")

    assert len(responses.calls) == 1
    assert isinstance(item, Item)
    assert item.id == example_item["_id"]
    assert item.title == example_item["title"] 
开发者ID:tsifrer,项目名称:python-twitch-client,代码行数:20,代码来源:test_collections.py

示例4: test_update

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_update():
    channel_id = example_channel["_id"]
    responses.add(
        responses.PUT,
        "{}channels/{}".format(BASE_URL, channel_id),
        body=json.dumps(example_channel),
        status=200,
        content_type="application/json",
    )

    client = TwitchClient("client id", "oauth token")
    status = "Spongebob Squarepants"
    channel = client.channels.update(channel_id, status=status)

    assert len(responses.calls) == 1
    expected_body = json.dumps({"channel": {"status": status}}).encode("utf-8")
    assert responses.calls[0].request.body == expected_body
    assert isinstance(channel, Channel)
    assert channel.id == channel_id
    assert channel.name == example_channel["name"] 
开发者ID:tsifrer,项目名称:python-twitch-client,代码行数:22,代码来源:test_channels.py

示例5: test_follow_channel

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_follow_channel():
    user_id = 1234
    channel_id = 12345
    responses.add(
        responses.PUT,
        "{}users/{}/follows/channels/{}".format(BASE_URL, user_id, channel_id),
        body=json.dumps(example_follow),
        status=200,
        content_type="application/json",
    )

    client = TwitchClient("client id", "oauth token")

    follow = client.users.follow_channel(user_id, channel_id)

    assert len(responses.calls) == 1
    assert isinstance(follow, Follow)
    assert follow.notifications == example_follow["notifications"]
    assert isinstance(follow.channel, Channel)
    assert follow.channel.id == example_channel["_id"]
    assert follow.channel.name == example_channel["name"] 
开发者ID:tsifrer,项目名称:python-twitch-client,代码行数:23,代码来源:test_users.py

示例6: test_block_user

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_block_user():
    user_id = 1234
    blocked_user_id = 12345
    responses.add(
        responses.PUT,
        "{}users/{}/blocks/{}".format(BASE_URL, user_id, blocked_user_id),
        body=json.dumps(example_block),
        status=200,
        content_type="application/json",
    )

    client = TwitchClient("client id", "oauth token")

    block = client.users.block_user(user_id, blocked_user_id)

    assert len(responses.calls) == 1
    assert isinstance(block, UserBlock)
    assert block.id == example_block["_id"]
    assert isinstance(block.user, User)
    assert block.user.id == example_user["_id"]
    assert block.user.name == example_user["name"] 
开发者ID:tsifrer,项目名称:python-twitch-client,代码行数:23,代码来源:test_users.py

示例7: test_update_feature

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_update_feature():
    """Feature update works."""

    def request_callback(request):
        payload = json.loads(request.body.decode())
        assert payload == {'type': 'Feature'}
        return (200, {}, "")

    responses.add_callback(
        responses.PUT,
        'https://api.mapbox.com/datasets/v1/{0}/{1}/features/{2}?access_token={3}'.format(
            username, 'test', '1', access_token),
        match_querystring=True,
        callback=request_callback)

    response = Datasets(access_token=access_token).update_feature(
        'test', '1', {'type': 'Feature'})
    assert response.status_code == 200 
开发者ID:mapbox,项目名称:mapbox-sdk-py,代码行数:20,代码来源:test_datasets.py

示例8: test_update_enterprise_catalog

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_update_enterprise_catalog():
    expected_response = {
        'catalog_uuid': TEST_ENTERPRISE_CATALOG_UUID,
        'enterprise_customer': TEST_ENTERPRISE_ID,
        'enterprise_customer_name': TEST_ENTERPRISE_NAME,
        'title': 'Test Catalog',
        'content_filter': {"content_type": "course"},
        'enabled_course_modes': ["verified"],
        'publish_audit_enrollment_urls': False,
    }
    responses.add(
        responses.PUT,
        _url("enterprise-catalogs/{catalog_uuid}/".format(catalog_uuid=TEST_ENTERPRISE_CATALOG_UUID)),
        json=expected_response,
    )
    client = enterprise_catalog.EnterpriseCatalogApiClient('staff-user-goes-here')
    actual_response = client.update_enterprise_catalog(
        TEST_ENTERPRISE_CATALOG_UUID,
        content_filter={"content_type": "course"}
    )
    assert actual_response == expected_response
    request = responses.calls[0][0]
    assert json.loads(request.body) == {'content_filter': {"content_type": "course"}} 
开发者ID:edx,项目名称:edx-enterprise,代码行数:25,代码来源:test_enterprise_catalog.py

示例9: test_edit_tag

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_edit_tag(self, manager):

        Mock.mock_get('tag/TheTestTag')
        tag = manager.get_tag('TheTestTag')

        responses.add_callback(
            responses.PUT,
            Mock.base_url + '/tag/TheTestTag',
            content_type='application/json',
            callback=tag_post_callback
        )

        tag.name = 'AnotherTestTag'
        assert tag._api_name == 'TheTestTag'

        tag.save()

        assert tag.name == 'AnotherTestTag'
        assert tag._api_name == 'AnotherTestTag' 
开发者ID:UpCloudLtd,项目名称:upcloud-python-api,代码行数:21,代码来源:test_tags.py

示例10: test_modify_gtt

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_modify_gtt(kiteconnect):
    """Test modify gtt order."""
    responses.add(
        responses.PUT,
        "{0}{1}".format(kiteconnect.root, kiteconnect._routes["gtt.modify"].format(trigger_id=123)),
        body=utils.get_response("gtt.modify"),
        content_type="application/json"
    )
    gtts = kiteconnect.modify_gtt(
        trigger_id=123,
        trigger_type=kiteconnect.GTT_TYPE_SINGLE,
        tradingsymbol="INFY",
        exchange="NSE",
        trigger_values=[1],
        last_price=800,
        orders=[{
            "transaction_type": kiteconnect.TRANSACTION_TYPE_BUY,
            "quantity": 1,
            "order_type": kiteconnect.ORDER_TYPE_LIMIT,
            "product": kiteconnect.PRODUCT_CNC,
            "price": 1,
        }]
    )
    assert gtts["trigger_id"] == 123 
开发者ID:zerodhatech,项目名称:pykiteconnect,代码行数:26,代码来源:test_connect.py

示例11: test_relabel_node_403_status

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_relabel_node_403_status(patch1, patch2):
    """
    Test relabel node with 403 resp status
    """
    responses.add(
        responses.PUT,
        'http://promhost:80/api/v1.0/node-labels/n1',
        body='{"key1":"label1"}',
        status=403)

    prom_client = PromenadeClient()

    with pytest.raises(errors.ClientForbiddenError):
        prom_client.relabel_node('n1', {"key1": "label1"}) 
开发者ID:airshipit,项目名称:drydock,代码行数:16,代码来源:test_k8sdriver_promenade_client.py

示例12: test_relabel_node_401_status

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_relabel_node_401_status(patch1, patch2):
    """
    Test relabel node with 401 resp status
    """
    responses.add(
        responses.PUT,
        'http://promhost:80/api/v1.0/node-labels/n1',
        body='{"key1":"label1"}',
        status=401)

    prom_client = PromenadeClient()

    with pytest.raises(errors.ClientUnauthorizedError):
        prom_client.relabel_node('n1', {"key1": "label1"}) 
开发者ID:airshipit,项目名称:drydock,代码行数:16,代码来源:test_k8sdriver_promenade_client.py

示例13: test_cli_dataset_put_feature_inline

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_cli_dataset_put_feature_inline():
    dataset = "dataset-2"
    id = "abc"

    feature = """
        {{
          "type":"Feature",
          "id":"{0}",
          "properties":{{}},
          "geometry":{{"type":"Point","coordinates":[0,0]}}
        }}""".format(id)

    feature = "".join(feature.split())

    responses.add(
        responses.PUT,
        'https://api.mapbox.com/datasets/v1/{0}/{1}/features/{2}?access_token={3}'.format(username, dataset, id, access_token),
        match_querystring=True,
        status=200, body=feature,
        content_type='application/json'
    )

    runner = CliRunner()
    result = runner.invoke(
        main_group,
        ['--access-token', access_token,
         'datasets',
         'put-feature', dataset, id, feature])

    assert result.exit_code == 0
    assert result.output.strip() == feature.strip() 
开发者ID:mapbox,项目名称:mapbox-cli-py,代码行数:33,代码来源:test_datasets.py

示例14: test_cli_dataset_put_feature_fromfile

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_cli_dataset_put_feature_fromfile(tmpdir):
    tmpfile = str(tmpdir.join('test.put-feature.json'))
    dataset = "dataset-2"
    id = "abc"

    feature = """
        {{
          "type":"Feature",
          "id":"{0}",
          "properties":{{}},
          "geometry":{{"type":"Point","coordinates":[0,0]}}
        }}""".format(id)

    feature = "".join(feature.split())

    f = open(tmpfile, 'w')
    f.write(feature)
    f.close()

    responses.add(
        responses.PUT,
        'https://api.mapbox.com/datasets/v1/{0}/{1}/features/{2}?access_token={3}'.format(username, dataset, id, access_token),
        match_querystring=True,
        status=200, body=feature,
        content_type='application/json'
    )

    runner = CliRunner()
    result = runner.invoke(
        main_group,
        ['--access-token', access_token,
         'datasets',
         'put-feature', dataset, id,
         '--input', tmpfile])

    assert result.exit_code == 0
    assert result.output.strip() == feature.strip() 
开发者ID:mapbox,项目名称:mapbox-cli-py,代码行数:39,代码来源:test_datasets.py

示例15: test_cli_dataset_put_feature_stdin

# 需要导入模块: import responses [as 别名]
# 或者: from responses import PUT [as 别名]
def test_cli_dataset_put_feature_stdin():
    dataset = "dataset-2"
    id = "abc"

    feature = """
        {{
          "type":"Feature",
          "id":"{0}",
          "properties":{{}},
          "geometry":{{"type":"Point","coordinates":[0,0]}}
        }}""".format(id)

    feature = "".join(feature.split())

    responses.add(
        responses.PUT,
        'https://api.mapbox.com/datasets/v1/{0}/{1}/features/{2}?access_token={3}'.format(username, dataset, id, access_token),
        match_querystring=True,
        status=200, body=feature,
        content_type='application/json'
    )

    runner = CliRunner()
    result = runner.invoke(
        main_group,
        ['--access-token', access_token,
         'datasets',
         'put-feature', dataset, id],
        input=feature)

    assert result.exit_code == 0
    assert result.output.strip() == feature.strip() 
开发者ID:mapbox,项目名称:mapbox-cli-py,代码行数:34,代码来源:test_datasets.py


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