當前位置: 首頁>>代碼示例>>Python>>正文


Python responses.PATCH屬性代碼示例

本文整理匯總了Python中responses.PATCH屬性的典型用法代碼示例。如果您正苦於以下問題:Python responses.PATCH屬性的具體用法?Python responses.PATCH怎麽用?Python responses.PATCH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在responses的用法示例。


在下文中一共展示了responses.PATCH屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_pr_synchronize_callback

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_pr_synchronize_callback(self, config):
        """Test that a snooze label is removed from PRs when a new commit is
        pushed."""
        responses.add(
            responses.PATCH,
            "https://api.github.com/repos/octocat/Hello-World/issues/1347")
        responses.add(
            responses.GET,
            "https://api.github.com/repos/baxterthehacker/public-repo/issues/1",
            body=github_responses.SNOOZED_ISSUE_GET)
        r = snooze.github_callback(
            "pull_request",
            json.loads(github_responses.PULL_REQUEST),
            (config["github_username"], config["github_token"]),
            config["snooze_label"],
            config["ignore_members_of"])
        assert r is True
        assert len(responses.calls) == 2 
開發者ID:tdsmith,項目名稱:github-snooze-button,代碼行數:20,代碼來源:test_callbacks.py

示例2: test_perform_checksum

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_perform_checksum(self):
        self.uploader.upload_checksum = True
        tus_request = request.TusRequest(self.uploader)

        with open('LICENSE', 'r') as stream, responses.RequestsMock() as resps:
            license_ = stream.read()
            encoded_file = license_.encode('utf-8')
            expected_checksum = "sha1 " + \
                base64.standard_b64encode(hashlib.sha1(
                    encoded_file).digest()).decode("ascii")

            sent_checksum = ''
            def validate_headers(req):
                nonlocal sent_checksum
                sent_checksum = req.headers['upload-checksum']
                return (204, {}, None)

            resps.add_callback(responses.PATCH, self.url, callback=validate_headers)
            tus_request.perform()
            self.assertEqual(sent_checksum, expected_checksum) 
開發者ID:tus,項目名稱:tus-py-client,代碼行數:22,代碼來源:test_request.py

示例3: test_cli_dataset_update_dataset

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_cli_dataset_update_dataset():
    id = "cii9dtexw0039uelz7nzk1lq3"
    name = "the-name"
    description = "the-description"
    created = """
    {{"owner":"{username}",
      "id":"{id}",
      "name":{name},
      "description":{description},
      "created":"2015-12-16T22:20:38.847Z",
      "modified":"2015-12-16T22:20:38.847Z"}}
    """.format(username=username, id=id, name=name, description=description)

    created = "".join(created.split())

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

    runner = CliRunner()
    result = runner.invoke(
        main_group,
        ['--access-token', access_token,
         'datasets',
         'update-dataset', id,
         '--name', name,
         '-d', description])

    assert result.exit_code == 0
    assert result.output.strip() == created.strip() 
開發者ID:mapbox,項目名稱:mapbox-cli-py,代碼行數:35,代碼來源:test_datasets.py

示例4: test_issue_comment_callback

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_issue_comment_callback(self, config):
        """Test that a snooze label is removed from issues when a new comment
        is received."""
        responses.add(
            responses.PATCH,
            "https://api.github.com/repos/baxterthehacker/public-repo/issues/2")
        r = snooze.github_callback(
            "issue_comment",
            json.loads(github_responses.SNOOZED_ISSUE_COMMENT),
            (config["github_username"], config["github_token"]),
            config["snooze_label"],
            config["ignore_members_of"])
        assert r is True
        assert len(responses.calls) == 1

        org_url = "https://api.github.com/orgs/fellowship/members/baxterthehacker"
        responses.add(responses.GET, org_url, status=204)  # is a member
        r = snooze.github_callback(
            "issue_comment",
            json.loads(github_responses.SNOOZED_ISSUE_COMMENT),
            (config["github_username"], config["github_token"]),
            config["snooze_label"],
            ignore_members_of="fellowship")
        assert r is False

        orc_url = "https://api.github.com/orgs/orcs/members/baxterthehacker"
        responses.add(responses.GET, orc_url, status=404)  # is not a member
        r = snooze.github_callback(
            "issue_comment",
            json.loads(github_responses.SNOOZED_ISSUE_COMMENT),
            (config["github_username"], config["github_token"]),
            config["snooze_label"],
            ignore_members_of="orcs")
        assert r is True 
開發者ID:tdsmith,項目名稱:github-snooze-button,代碼行數:36,代碼來源:test_callbacks.py

示例5: test_pr_commit_comment_callback

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_pr_commit_comment_callback(self, config):
        """Test that a snooze label is removed from PRs when a new commit is
        pushed."""
        responses.add(
            responses.PATCH,
            "https://api.github.com/repos/octocat/Hello-World/issues/1347")
        responses.add(
            responses.GET,
            "https://api.github.com/repos/baxterthehacker/public-repo/issues/1",
            body=github_responses.SNOOZED_ISSUE_GET)
        r = snooze.github_callback(
            "pull_request_review_comment",
            json.loads(github_responses.PULL_REQUEST_REVIEW_COMMENT),
            (config["github_username"], config["github_token"]),
            config["snooze_label"],
            config["ignore_members_of"])
        assert r is True
        assert len(responses.calls) == 2

        org_url = "https://api.github.com/orgs/fellowship/members/baxterthehacker"
        responses.add(responses.GET, org_url, status=204)  # is a member
        r = snooze.github_callback(
            "pull_request_review_comment",
            json.loads(github_responses.PULL_REQUEST_REVIEW_COMMENT),
            (config["github_username"], config["github_token"]),
            config["snooze_label"],
            ignore_members_of="fellowship")
        assert r is False

        orc_url = "https://api.github.com/orgs/orcs/members/baxterthehacker"
        responses.add(responses.GET, orc_url, status=404)  # is not a member
        r = snooze.github_callback(
            "pull_request_review_comment",
            json.loads(github_responses.PULL_REQUEST_REVIEW_COMMENT),
            (config["github_username"], config["github_token"]),
            config["snooze_label"],
            ignore_members_of="orcs")
        assert r is True 
開發者ID:tdsmith,項目名稱:github-snooze-button,代碼行數:40,代碼來源:test_callbacks.py

示例6: patch

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def patch(self, url, filename, status=200):
        """Setup a mock response for a PATCH request."""
        body = self._get_body(filename)
        self.add(responses.PATCH, url, body=body, status=status, content_type='application/hal+json') 
開發者ID:mollie,項目名稱:mollie-api-python,代碼行數:6,代碼來源:conftest.py

示例7: mock_edit_release

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def mock_edit_release(self, body=None, draft=True, prerelease=False):
        if body is None:
            body = "Test release body"
        responses.add(
            method=responses.PATCH,
            url="{}/releases/1".format(self.repo_url),
            json=self._get_expected_release(
                "1", body=body, draft=draft, prerelease=prerelease
            ),
            status=http.client.OK,
        ) 
開發者ID:SFDO-Tooling,項目名稱:CumulusCI,代碼行數:13,代碼來源:utils.py

示例8: test_activate_some_flow_processes

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_activate_some_flow_processes(self):
        cc_task = create_task(
            ActivateFlow,
            {
                "developer_names": [
                    "Auto_Populate_Date_And_Name_On_Program_Engagement",
                    "ape",
                ],
            },
        )
        record_id = "3001F0000009GFwQAM"
        activate_url = "{}/services/data/v43.0/tooling/sobjects/FlowDefinition/{}".format(
            cc_task.org_config.instance_url, record_id
        )
        responses.add(
            method="GET",
            url="https://test.salesforce.com/services/data/v43.0/tooling/query/?q=SELECT+Id%2C+ActiveVersion.VersionNumber%2C+LatestVersion.VersionNumber%2C+DeveloperName+FROM+FlowDefinition+WHERE+DeveloperName+IN+%28%27Auto_Populate_Date_And_Name_On_Program_Engagement%27%2C%27ape%27%29",
            body=json.dumps(
                {
                    "records": [
                        {
                            "Id": record_id,
                            "DeveloperName": "Auto_Populate_Date_And_Name_On_Program_Engagement",
                            "LatestVersion": {"VersionNumber": 1},
                        }
                    ]
                }
            ),
            status=200,
        )
        data = {"Metadata": {"activeVersionNumber": 1}}
        responses.add(method=responses.PATCH, url=activate_url, status=204, json=data)

        cc_task()
        self.assertEqual(2, len(responses.calls)) 
開發者ID:SFDO-Tooling,項目名稱:CumulusCI,代碼行數:37,代碼來源:test_activate_flow.py

示例9: test_dataset_update

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_dataset_update():
    """Updating dataset name and description works."""

    def request_callback(request):
        payload = json.loads(request.body.decode())
        resp_body = {
            'owner': username,
            'id': 'foo',
            'name': payload['name'],
            'description': payload['description'],
            'created': '2015-09-19',
            'modified': '2015-09-19'}
        headers = {}
        return (200, headers, json.dumps(resp_body))

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

    response = Datasets(access_token=access_token).update_dataset(
        'foo', name='things', description='a collection of things')
    assert response.status_code == 200
    assert response.json()['name'] == 'things'
    assert response.json()['description'] == 'a collection of things' 
開發者ID:mapbox,項目名稱:mapbox-sdk-py,代碼行數:29,代碼來源:test_datasets.py

示例10: test_update_exam_attempt_status

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_update_exam_attempt_status(self, provider_method_name, corresponding_status):
        attempt_id = 2
        responses.add(
            responses.PATCH,
            url=self.provider.exam_attempt_url.format(exam_id=self.backend_exam['external_id'], attempt_id=attempt_id),
            json={'id': 2, 'status': corresponding_status}
        )
        status = getattr(self.provider, provider_method_name)(self.backend_exam['external_id'], attempt_id)
        self.assertEqual(status, corresponding_status) 
開發者ID:edx,項目名稱:edx-proctoring,代碼行數:11,代碼來源:test_rest.py

示例11: test_malformed_json_in_response

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_malformed_json_in_response(self):
        attempt_id = 2
        responses.add(
            responses.PATCH,
            url=self.provider.exam_attempt_url.format(exam_id=self.backend_exam['external_id'], attempt_id=attempt_id),
            body='"]'
        )
        status = self.provider.mark_erroneous_exam_attempt(self.backend_exam['external_id'], attempt_id)
        # the important thing is that it didn't raise an exception for bad json
        self.assertEqual(status, None) 
開發者ID:edx,項目名稱:edx-proctoring,代碼行數:12,代碼來源:test_rest.py

示例12: test_perform

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_perform(self):
        with open('LICENSE', 'rb') as stream, responses.RequestsMock() as resps:
            size = stream.tell()
            resps.add(responses.PATCH, self.url,
                      adding_headers={'upload-offset': str(size)},
                      status=204)

            self.request.perform()
            self.assertEqual(str(size), self.request.response_headers['upload-offset']) 
開發者ID:tus,項目名稱:tus-py-client,代碼行數:11,代碼來源:test_request.py

示例13: test_update_entity

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_update_entity(service):
    """Check updating of entity properties"""

    # pylint: disable=redefined-outer-name

    responses.add(
        responses.PATCH,
        "{0}/TemperatureMeasurements(Sensor='sensor1',Date=datetime'2017-12-24T18:00:00')".format(service.url),
        json={'d': {
            'Sensor': 'Sensor-address',
            'Date': "/Date(1714138400000)/",
            'Value': '34.0d'
        }},
        status=204)

    request = service.entity_sets.TemperatureMeasurements.update_entity(
        Sensor='sensor1',
        Date=datetime.datetime(2017, 12, 24, 18, 0))

    assert isinstance(request, pyodata.v2.service.EntityModifyRequest)

    request.set(Value=34.0)
    # Tests if update entity correctly calls 'to_json' method
    request.set(Date=datetime.datetime(2017, 12, 24, 19, 0))

    assert request._values['Value'] == '3.400000E+01'
    assert request._values['Date'] == '/Date(1514142000000)/'

    # If preformatted datetime is passed (e. g. you already replaced datetime instance with string which is
    # complaint with odata specification), 'to_json' does not update given value (for backward compatibility reasons)
    request.set(Date='/Date(1714138400000)/')
    assert request._values['Date'] == '/Date(1714138400000)/'

    request.execute() 
開發者ID:SAP,項目名稱:python-pyodata,代碼行數:36,代碼來源:test_service_v2.py

示例14: test_update_entity_with_patch_method_specified

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_update_entity_with_patch_method_specified(service):
    """Make sure the method update_entity handles correctly when PATCH method is specified"""

    # pylint: disable=redefined-outer-name


    key = EntityKey(
        service.schema.entity_type('TemperatureMeasurement'),
        Sensor='sensor1',
        Date=datetime.datetime(2017, 12, 24, 18, 0))

    query = service.entity_sets.TemperatureMeasurements.update_entity(key, method="PATCH")
    assert query.get_method() == "PATCH" 
開發者ID:SAP,項目名稱:python-pyodata,代碼行數:15,代碼來源:test_service_v2.py

示例15: test_update_entity_with_no_method_specified

# 需要導入模塊: import responses [as 別名]
# 或者: from responses import PATCH [as 別名]
def test_update_entity_with_no_method_specified(service):
    """Make sure the method update_entity handles correctly when no method is specified"""

    # pylint: disable=redefined-outer-name


    key = EntityKey(
        service.schema.entity_type('TemperatureMeasurement'),
        Sensor='sensor1',
        Date=datetime.datetime(2017, 12, 24, 18, 0))

    query = service.entity_sets.TemperatureMeasurements.update_entity(key)
    assert query.get_method() == "PATCH" 
開發者ID:SAP,項目名稱:python-pyodata,代碼行數:15,代碼來源:test_service_v2.py


注:本文中的responses.PATCH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。