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


Python httpretty.PUT属性代码示例

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


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

示例1: test_update

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_update(self):
        """:meth:`update` should return a dictionary of the updated record"""

        httpretty.register_uri(
            httpretty.GET,
            self.mock_url_builder_base,
            body=get_serialized_result(self.record_response_get_one),
            status=200,
            content_type="application/json",
        )

        httpretty.register_uri(
            httpretty.PUT,
            self.mock_url_builder_sys_id,
            body=get_serialized_result(self.record_response_update),
            status=200,
            content_type="application/json",
        )

        response = self.resource.update(self.dict_query, self.record_response_update)
        result = response.one()

        self.assertEquals(type(result), dict)
        self.assertEquals(self.record_response_update["attr1"], result["attr1"]) 
开发者ID:rbw,项目名称:pysnow,代码行数:26,代码来源:test_resource.py

示例2: test_get_or_create_db

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_get_or_create_db():
    server = Server("http://test.test:5984")
    httpretty.register_uri(
        httpretty.HEAD, "http://test.test:5984/test", status=404, body=""
    )
    def create_test_db(request, uri, headers):
        httpretty.reset()
        httpretty.register_uri(
            httpretty.HEAD, "http://test.test:5984/test", status=200
        )
        httpretty.register_uri(
            httpretty.PUT, "http://test.test:5984/test", status=500
        )
        return 201, headers, ""
    httpretty.register_uri(
        httpretty.PUT, "http://test.test:5984/test", body=create_test_db
    )
    assert "test" not in server
    test_db = server.get_or_create("test")
    assert "test" in server 
开发者ID:OpenAgricultureFoundation,项目名称:openag_python,代码行数:22,代码来源:test_couch.py

示例3: test_upload_repo

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_upload_repo(self):
        httpretty.register_uri(
            httpretty.PUT,
            BaseApiHandler.build_url(
                self.api_config.base_url,
                '/',
                'user',
                'project',
                'repo',
                'upload'),
            content_type='application/json',
            status=200)
        files = [('code', ('repo',
                           open('./tests/fixtures_static/repo.tar.gz', 'rb'),
                           'text/plain'))]
        result = self.api_handler.upload_repo('user', 'project', files=files, files_size=10)
        assert result.status_code == 200

        # Async
        self.assert_async_call(
            api_handler_call=lambda: self.api_handler.upload_repo(
                'user', 'project', files=files, files_size=10, background=True),
            method='upload') 
开发者ID:polyaxon,项目名称:polyaxon-client,代码行数:25,代码来源:test_project.py

示例4: test_update_incident

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_update_incident(self):
        """
        Updates an existing incident. Checks for sys_id and status code 200
        """
        json_body = json.dumps(
            {"result": [{"sys_id": self.mock_incident["sys_id"], "this": "that"}]}
        )
        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        httpretty.register_uri(
            httpretty.PUT,
            "http://%s/%s/%s"
            % (
                self.mock_connection["host"],
                self.mock_incident["path"],
                self.mock_incident["sys_id"],
            ),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        r = self.client.query(
            table="incident", query={"number": self.mock_incident["number"]}
        )
        result = r.update({"this": "that"})

        # Make sure we got an incident back with the expected sys_id
        self.assertEqual(result[0]["sys_id"], self.mock_incident["sys_id"])
        self.assertEqual(result[0]["this"], "that")
        self.assertEqual(r.status_code, 200) 
开发者ID:rbw,项目名称:pysnow,代码行数:39,代码来源:test_request.py

示例5: test_update_incident_non_existent

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_update_incident_non_existent(self):
        """
        Attempt to update a non-existent incident
        """
        json_body = json.dumps({"result": {}})
        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        httpretty.register_uri(
            httpretty.PUT,
            "http://%s/%s/%s"
            % (
                self.mock_connection["host"],
                self.mock_incident["path"],
                self.mock_incident["sys_id"],
            ),
            body={},
            status=200,
            content_type="application/json",
        )

        r = self.client.query(
            table="incident", query={"number": self.mock_incident["number"]}
        )
        self.assertRaises(NoResults, r.update, {"foo": "bar"}) 
开发者ID:rbw,项目名称:pysnow,代码行数:32,代码来源:test_request.py

示例6: test_update_incident_invalid_update

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_update_incident_invalid_update(self):
        """
        Make sure updates which are non-dict and non-string type are properly handled
        """
        json_body = json.dumps(
            {"result": [{"sys_id": self.mock_incident["sys_id"], "this": "that"}]}
        )
        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        httpretty.register_uri(
            httpretty.PUT,
            "http://%s/%s/%s"
            % (
                self.mock_connection["host"],
                self.mock_incident["path"],
                self.mock_incident["sys_id"],
            ),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        r = self.client.query(
            table="incident", query={"number": self.mock_incident["number"]}
        )
        self.assertRaises(InvalidUsage, r.update, "invalid update") 
开发者ID:rbw,项目名称:pysnow,代码行数:34,代码来源:test_request.py

示例7: test_update_incident_multiple

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_update_incident_multiple(self):
        """
        Make sure update queries yielding more than 1 record fails
        """
        json_body = json.dumps(
            {
                "result": [
                    {"sys_id": self.mock_incident["sys_id"], "this": "that"},
                    {"sys_id": self.mock_incident["sys_id"], "this": "that"},
                ]
            }
        )

        httpretty.register_uri(
            httpretty.GET,
            "http://%s/%s" % (self.mock_connection["host"], self.mock_incident["path"]),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        httpretty.register_uri(
            httpretty.PUT,
            "http://%s/%s/%s"
            % (
                self.mock_connection["host"],
                self.mock_incident["path"],
                self.mock_incident["sys_id"],
            ),
            body=json_body,
            status=200,
            content_type="application/json",
        )

        r = self.client.query(
            table="incident", query={"number": self.mock_incident["number"]}
        )
        self.assertRaises(MultipleResults, r.update, {"foo": "bar"}) 
开发者ID:rbw,项目名称:pysnow,代码行数:40,代码来源:test_request.py

示例8: test_create_user

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_create_user():
    server = Server("http://test.test:5984")
    httpretty.register_uri(
        httpretty.HEAD, "http://test.test:5984/_users"
    )
    httpretty.register_uri(
        httpretty.PUT, "http://test.test:5984/_users/org.couchdb.user%3Atest",
        status=201
    )
    server.create_user("test", "test") 
开发者ID:OpenAgricultureFoundation,项目名称:openag_python,代码行数:12,代码来源:test_couch.py

示例9: test_init_without_cloud_server

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_init_without_cloud_server(
    config, push_design_documents, get_or_create, generate_config
):
    runner = CliRunner()

    generate_config.return_value = {"test": {"test": "test"}}
    httpretty.register_uri(
        httpretty.GET, "http://localhost:5984/_config/test/test",
        body='"test_val"'
    )
    httpretty.register_uri(
        httpretty.PUT, "http://localhost:5984/_config/test/test"
    )

    # Show -- Should throw an error because no local server is selected
    res = runner.invoke(show)
    assert res.exit_code, res.output

    # Init -- Should work and push the design documents but not replicate
    # anything
    res = runner.invoke(init)
    assert res.exit_code == 0, res.exception or res.output
    assert get_or_create.call_count == len(all_dbs)
    assert push_design_documents.call_count == 1
    push_design_documents.reset_mock()

    # Show -- Should work
    res = runner.invoke(show)
    assert res.exit_code == 0, res.exception or res.output

    # Init -- Should throw an error because a different database is already
    # selected
    res = runner.invoke(init, ["--db_url", "http://test.test:5984"])
    assert res.exit_code, res.output 
开发者ID:OpenAgricultureFoundation,项目名称:openag_python,代码行数:36,代码来源:test_db.py

示例10: _mock_commerce_api

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def _mock_commerce_api(self, status=200, body=None):
        self.assertTrue(httpretty.is_enabled(), 'httpretty must be enabled to mock Commerce API calls.')

        body = body or {}
        url = self.site_configuration.build_lms_url('/api/commerce/v1/courses/{}/'.format(self.course.id))
        httpretty.register_uri(httpretty.PUT, url, status=status, body=json.dumps(body), content_type=JSON) 
开发者ID:edx,项目名称:ecommerce,代码行数:8,代码来源:test_publishers.py

示例11: mock_creditcourse_endpoint

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def mock_creditcourse_endpoint(self, course_id, status, body=None):
        self.assertTrue(httpretty.is_enabled(), 'httpretty must be enabled to mock Credit API calls.')

        url = get_lms_url('/api/credit/v1/courses/{}/'.format(course_id))
        httpretty.register_uri(
            httpretty.PUT,
            url,
            status=status,
            body=json.dumps(body),
            content_type=JSON
        ) 
开发者ID:edx,项目名称:ecommerce,代码行数:13,代码来源:test_publishers.py

示例12: test_upload_and_sync_repo

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_upload_and_sync_repo(self):
        httpretty.register_uri(
            httpretty.PUT,
            BaseApiHandler.build_url(
                self.api_config.base_url,
                '/',
                'user',
                'project',
                'repo',
                'upload'),
            content_type='application/json',
            status=200)
        files = [('code', ('repo',
                           open('./tests/fixtures_static/repo.tar.gz', 'rb'),
                           'text/plain'))]
        result = self.api_handler.upload_repo('user',
                                              'project',
                                              files=files,
                                              files_size=10,
                                              sync=True)
        assert result.status_code == 200

        # Async
        self.assert_async_call(
            api_handler_call=lambda: self.api_handler.upload_repo(
                'user', 'project', files=files, files_size=10, sync=True, background=True),
            method='upload') 
开发者ID:polyaxon,项目名称:polyaxon-client,代码行数:29,代码来源:test_project.py

示例13: test_put_method_called

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_put_method_called(self):

        httpretty.register_uri(
            httpretty.PUT,
            self.endpoint_url("/customer/4013"),
            content_type='text/json',
            body='{"status": true, "contributors": null}',
            status=302,
        )

        req = PayStackRequests()
        response = req.put('customer/4013',
                           data={'test': 'requests'})
        self.assertTrue(response['status']) 
开发者ID:andela-sjames,项目名称:paystack-python,代码行数:16,代码来源:test_base.py

示例14: test_update

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_update(self):
        """Method defined to test paystackapi customer update."""
        httpretty.register_uri(
            httpretty.PUT,
            self.endpoint_url("/customer/4013"),
            content_type='text/json',
            body='{"status": true, "contributors": true}',
            status=201,
        )

        response = Customer.update(customer_id=4013, first_name='andela')
        self.assertEqual(response['status'], True) 
开发者ID:andela-sjames,项目名称:paystack-python,代码行数:14,代码来源:test_customer.py

示例15: test_product_update

# 需要导入模块: import httpretty [as 别名]
# 或者: from httpretty import PUT [as 别名]
def test_product_update(self):
        """Method defined to test Product update."""
        httpretty.register_uri(
            httpretty.PUT,
            self.endpoint_url("/product/5499"),
            content_type='text/json',
            body='{"status": true, "message": "Products retrieved", "data":[{}]}',
            status=201,
        )

        response = Product.update(product_id=5499, name="Product pypaystack test",
            description="my test description", price=500000000,
            currency="USD"
        )
        self.assertEqual(response['status'], True) 
开发者ID:andela-sjames,项目名称:paystack-python,代码行数:17,代码来源:test_product.py


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