Python httpretty 模块,DELETE 实例源码

我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用httpretty.DELETE

项目:cloudstrype    作者:btimby    | 项目源码 | 文件源码
def test_delete(self):
        httpretty.register_uri(
            httpretty.DELETE,
            OnedriveAPIClient.DELETE_URL[1].format(path=self._get_path()),
            body=TEST_CHUNK_BODY)

        self.client.delete(self.chunk)
项目:cloudstrype    作者:btimby    | 项目源码 | 文件源码
def test_delete(self):
        # Box requires the file id in the URL, the file_id is assigned by Box,
        # and therefore is stored in ChunkStorage.attrs.
        httpretty.register_uri(
            httpretty.DELETE,
            BoxAPIClient.DELETE_URL[1].format(file_id='abc123'),
            body=TEST_CHUNK_BODY)

        self.client.delete(self.chunk)
项目:cloudstrype    作者:btimby    | 项目源码 | 文件源码
def test_delete(self):
        # GDrive requires the file id in the URL, the file_id is assigned by
        # Google, and therefore is stored in ChunkStorage.attrs.
        httpretty.register_uri(
            httpretty.DELETE,
            GDriveAPIClient.DELETE_URL[1].format(file_id='abc123'),
            body=TEST_CHUNK_BODY)

        self.client.delete(self.chunk)
项目:cloudstrype    作者:btimby    | 项目源码 | 文件源码
def test_delete(self):
        httpretty.register_uri(
            httpretty.DELETE,
            OnedriveAPIClient.DELETE_URL[1].format(path=self._get_path()),
            body=TEST_CHUNK_BODY)

        self.client.delete(self.chunk)
项目:cloudstrype    作者:btimby    | 项目源码 | 文件源码
def test_delete(self):
        # Box requires the file id in the URL, the file_id is assigned by Box,
        # and therefore is stored in ChunkStorage.attrs.
        httpretty.register_uri(
            httpretty.DELETE,
            BoxAPIClient.DELETE_URL[1].format(file_id='abc123'),
            body=TEST_CHUNK_BODY)

        self.client.delete(self.chunk)
项目:cloudstrype    作者:btimby    | 项目源码 | 文件源码
def test_delete(self):
        httpretty.register_uri(
            httpretty.DELETE,
            OnedriveAPIClient.DELETE_URL[1].format(path=self._get_path()),
            body=TEST_CHUNK_BODY)

        self.client.delete(self.chunk)
项目:cloudstrype    作者:btimby    | 项目源码 | 文件源码
def test_delete(self):
        # Box requires the file id in the URL, the file_id is assigned by Box,
        # and therefore is stored in ChunkStorage.attrs.
        httpretty.register_uri(
            httpretty.DELETE,
            BoxAPIClient.DELETE_URL[1].format(file_id='abc123'),
            body=TEST_CHUNK_BODY)

        self.client.delete(self.chunk)
项目:cloudstrype    作者:btimby    | 项目源码 | 文件源码
def test_delete(self):
        # GDrive requires the file id in the URL, the file_id is assigned by
        # Google, and therefore is stored in ChunkStorage.attrs.
        httpretty.register_uri(
            httpretty.DELETE,
            GDriveAPIClient.DELETE_URL[1].format(file_id='abc123'),
            body=TEST_CHUNK_BODY)

        self.client.delete(self.chunk)
项目:openag_brain    作者:OpenAgInitiative    | 项目源码 | 文件源码
def test_cancel_replication():
    server = BootstrapServer("http://test.test:5984")
    httpretty.register_uri(
        httpretty.HEAD, "http://test.test:5984/_replicator",
        status=200
    )
    global doc_exists
    doc_exists = True
    def head_test_src(request, uri, headers):
        if doc_exists:
            return 200, headers, ""
        else:
            return 404, headers, ""
    httpretty.register_uri(
        httpretty.HEAD, "http://test.test:5984/_replicator/test_src",
        etag="a", body=head_test_src
    )
    def delete_test_src(request, uri, headers):
        global doc_exists
        doc_exists = False
        return 200, headers, ""
    httpretty.register_uri(
        httpretty.DELETE, "http://test.test:5984/_replicator/test_src",
        etag="a", body=delete_test_src
    )
    assert "test_src" in server["_replicator"]
    server.cancel_replication("test_src")
    assert "test_src" not in server["_replicator"]
项目:openag_python    作者:OpenAgInitiative    | 项目源码 | 文件源码
def test_cancel_replication():
    server = Server("http://test.test:5984")
    httpretty.register_uri(
        httpretty.HEAD, "http://test.test:5984/_replicator",
        status=200
    )
    global doc_exists
    doc_exists = True
    def head_test_src(request, uri, headers):
        if doc_exists:
            return 200, headers, ""
        else:
            return 404, headers, ""
    httpretty.register_uri(
        httpretty.HEAD, "http://test.test:5984/_replicator/test_src",
        etag="a", body=head_test_src
    )
    def delete_test_src(request, uri, headers):
        global doc_exists
        doc_exists = False
        return 200, headers, ""
    httpretty.register_uri(
        httpretty.DELETE, "http://test.test:5984/_replicator/test_src",
        etag="a", body=delete_test_src
    )
    assert "test_src" in server["_replicator"]
    server.cancel_replication("test_src")
    assert "test_src" not in server["_replicator"]
项目:ouroboros    作者:madedotcom    | 项目源码 | 文件源码
def given_a_user(self):
        self.start_mocking_http()
        self.expect_call('/users/foo', httpretty.DELETE)
        self.fake_response("/users/foo", file="user-foo.json")
项目:ouroboros    作者:madedotcom    | 项目源码 | 文件源码
def it_should_delete_the_user(self):
        expect(httpretty.last_request()).to(
            have_posted_to("/users/foo", method=httpretty.DELETE))
项目:swagger-stub    作者:Trax-air    | 项目源码 | 文件源码
def swagger_stub(swagger_files_url):
    """Fixture to stub a microservice from swagger files.

    To use this fixture you need to define a swagger fixture named
    swagger_files_url with the path to your swagger files, and the url to stub.
    Then just add this fixture to your tests and your request pointing to the
    urls in swagger_files_url will be managed by the stub.

    Example:
        @pytest.fixture
        def swagger_files_url():
            return [('tests/swagger.yaml', 'http://localhost:8000')]
    """
    httpretty.enable()

    for i in swagger_files_url:  # Get all given swagger files and url
        base_url = i[1]
        s = SwaggerParser(i[0])
        swagger_url[base_url] = s

        # Register all urls
        httpretty.register_uri(
            httpretty.GET, re.compile(base_url + r'/.*'),
            body=get_data_from_request)

        httpretty.register_uri(
            httpretty.POST, re.compile(base_url + r'/.*'),
            body=get_data_from_request)

        httpretty.register_uri(
            httpretty.PUT, re.compile(base_url + r'/.*'),
            body=get_data_from_request)

        httpretty.register_uri(
            httpretty.PATCH, re.compile(base_url + r'/.*'),
            body=get_data_from_request)

        httpretty.register_uri(
            httpretty.DELETE, re.compile(base_url + r'/.*'),
            body=get_data_from_request)

        memory[base_url] = StubMemory(s)
        yield memory[base_url]

    # Close httpretty
    httpretty.disable()
    httpretty.reset()
项目:openag_brain    作者:OpenAgInitiative    | 项目源码 | 文件源码
def test_replicate():
    # Start a replication
    server = BootstrapServer("http://test.test:5984")
    httpretty.register_uri(
        httpretty.HEAD, "http://test.test:5984/_replicator"
    )
    httpretty.register_uri(
        httpretty.HEAD, "http://test.test:5984/_replicator/test",
        status=404
    )
    def replicate_test_src(request, uri, headers):
        httpretty.reset()
        httpretty.register_uri(
            httpretty.HEAD, "http://test.test:5984/_replicator"
        )
        httpretty.register_uri(
            httpretty.HEAD, "http://test.test:5984/_replicator/test",
            status=200, etag="a"
        )
        return 201, headers, json.dumps({
            "id": "test_src", "rev": "a", "ok": True
        })
    httpretty.register_uri(
        httpretty.PUT, "http://test.test:5984/_replicator/test",
        status=201, content_type="application/json", body=replicate_test_src
    )
    server.replicate("test", "test_src", "test_dest", continuous=True)
    assert "test" in server["_replicator"]

    # Make sure replicate is idempotent
    httpretty.register_uri(
        httpretty.PUT, "http://test.test:5984/_replicator/test_src",
        status=500
    )
    server.replicate("test", "test_src", "test_dest", continuous=True)
    assert "test" in server["_replicator"]

    # Cancel the replication
    def cancel_test_replication(request, uri, headers):
        httpretty.reset()
        httpretty.register_uri(
            httpretty.HEAD, "http://test.test:5984/_replicator"
        )
        httpretty.register_uri(
            httpretty.HEAD, "http://test.test:5984/_replicator/test",
            status=404
        )
        return 200, headers, ""
    httpretty.register_uri(
        httpretty.DELETE, "http://test.test:5984/_replicator/test",
        status=200, body=cancel_test_replication
    )
    server.cancel_replication("test")
    assert "test" not in server["_replicator"]
项目:openag_python    作者:OpenAgInitiative    | 项目源码 | 文件源码
def test_replicate():
    # Start a replication
    server = Server("http://test.test:5984")
    httpretty.register_uri(
        httpretty.HEAD, "http://test.test:5984/_replicator"
    )
    httpretty.register_uri(
        httpretty.HEAD, "http://test.test:5984/_replicator/test",
        status=404
    )
    def replicate_test_src(request, uri, headers):
        httpretty.reset()
        httpretty.register_uri(
            httpretty.HEAD, "http://test.test:5984/_replicator"
        )
        httpretty.register_uri(
            httpretty.HEAD, "http://test.test:5984/_replicator/test",
            status=200, etag="a"
        )
        return 201, headers, json.dumps({
            "id": "test_src", "rev": "a", "ok": True
        })
    httpretty.register_uri(
        httpretty.PUT, "http://test.test:5984/_replicator/test",
        status=201, content_type="application/json", body=replicate_test_src
    )
    server.replicate("test", "test_src", "test_dest", continuous=True)
    assert "test" in server["_replicator"]

    # Make sure replicate is idempotent
    httpretty.register_uri(
        httpretty.PUT, "http://test.test:5984/_replicator/test_src",
        status=500
    )
    server.replicate("test", "test_src", "test_dest", continuous=True)
    assert "test" in server["_replicator"]

    # Cancel the replication
    def cancel_test_replication(request, uri, headers):
        httpretty.reset()
        httpretty.register_uri(
            httpretty.HEAD, "http://test.test:5984/_replicator"
        )
        httpretty.register_uri(
            httpretty.HEAD, "http://test.test:5984/_replicator/test",
            status=404
        )
        return 200, headers, ""
    httpretty.register_uri(
        httpretty.DELETE, "http://test.test:5984/_replicator/test",
        status=200, body=cancel_test_replication
    )
    server.cancel_replication("test")
    assert "test" not in server["_replicator"]