當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。