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


Python ViewSet.responses方法代码示例

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


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

示例1: test_class_parameters_are_used_for_collection_arguments

# 需要导入模块: from kinto.core.resource import ViewSet [as 别名]
# 或者: from kinto.core.resource.ViewSet import responses [as 别名]
    def test_class_parameters_are_used_for_collection_arguments(self, mocked):
        default_arguments = {"cors_headers": mock.sentinel.cors_headers}

        default_get_arguments = {"accept": mock.sentinel.accept}

        default_collection_arguments = {"cors_origins": mock.sentinel.cors_origins}

        collection_get_arguments = {"error_handler": mock.sentinel.error_handler}

        viewset = ViewSet(
            default_arguments=default_arguments,
            default_get_arguments=default_get_arguments,
            default_collection_arguments=default_collection_arguments,
            collection_get_arguments=collection_get_arguments,
        )

        viewset.responses = mock.MagicMock()
        arguments = viewset.collection_arguments(mock.MagicMock(), "get")

        self.assertDictEqual(
            arguments,
            {
                "schema": mocked().bind(),
                "accept": mock.sentinel.accept,
                "cors_headers": mock.sentinel.cors_headers,
                "cors_origins": mock.sentinel.cors_origins,
                "error_handler": mock.sentinel.error_handler,
                "validators": [colander_validator],
                "response_schemas": viewset.responses.get_and_bind(),
            },
        )
开发者ID:pombredanne,项目名称:kinto,代码行数:33,代码来源:test_viewset.py

示例2: test_default_arguments_are_copied_before_being_returned

# 需要导入模块: from kinto.core.resource import ViewSet [as 别名]
# 或者: from kinto.core.resource.ViewSet import responses [as 别名]
 def test_default_arguments_are_copied_before_being_returned(self):
     original_arguments = {}
     viewset = ViewSet(collection_get_arguments=original_arguments)
     viewset.responses = mock.MagicMock()
     arguments = viewset.collection_arguments(mock.MagicMock(), "GET")
     self.assertEqual(original_arguments, {})
     self.assertNotEquals(original_arguments, arguments)
开发者ID:pombredanne,项目名称:kinto,代码行数:9,代码来源:test_viewset.py

示例3: test_a_default_schema_is_added_when_method_doesnt_match

# 需要导入模块: from kinto.core.resource import ViewSet [as 别名]
# 或者: from kinto.core.resource.ViewSet import responses [as 别名]
    def test_a_default_schema_is_added_when_method_doesnt_match(self, mocked):
        viewset = ViewSet()
        resource = mock.MagicMock()
        viewset.responses = mock.MagicMock()
        mocked.Mapping.return_value = mock.sentinel.default_schema

        arguments = viewset.collection_arguments(resource, "GET")
        self.assertNotEqual(arguments["schema"], resource.schema)

        mocked.assert_called_with()
开发者ID:pombredanne,项目名称:kinto,代码行数:12,代码来源:test_viewset.py

示例4: test_service_arguments_arent_inherited_by_record_arguments

# 需要导入模块: from kinto.core.resource import ViewSet [as 别名]
# 或者: from kinto.core.resource.ViewSet import responses [as 别名]
    def test_service_arguments_arent_inherited_by_record_arguments(self, mocked):
        service_arguments = {"description": "The little book of calm"}

        default_arguments = {"cors_headers": mock.sentinel.cors_headers}
        viewset = ViewSet(
            default_arguments=default_arguments,
            service_arguments=service_arguments,
            default_record_arguments={},
            record_get_arguments={},
        )

        viewset.responses = mock.MagicMock()
        arguments = viewset.record_arguments(mock.MagicMock(), "get")

        self.assertDictEqual(
            arguments,
            {
                "schema": mocked().bind(),
                "cors_headers": mock.sentinel.cors_headers,
                "validators": [colander_validator],
                "response_schemas": viewset.responses.get_and_bind(),
            },
        )
开发者ID:pombredanne,项目名称:kinto,代码行数:25,代码来源:test_viewset.py

示例5: test_class_parameters_overwrite_each_others

# 需要导入模块: from kinto.core.resource import ViewSet [as 别名]
# 或者: from kinto.core.resource.ViewSet import responses [as 别名]
    def test_class_parameters_overwrite_each_others(self, mocked):
        # Some class parameters should overwrite each others.
        # The more specifics should prevail over the more generics.
        # Items annoted with a "<<" are the one that should prevail.
        default_arguments = {
            "cors_origins": mock.sentinel.default_cors_origins,
            "error_handler": mock.sentinel.default_error_handler,
            "cors_headers": mock.sentinel.default_cors_headers,  # <<
        }
        default_record_arguments = {
            "cors_origins": mock.sentinel.default_record_cors_origin,
            "error_handler": mock.sentinel.default_record_error_handler,  # <<
        }

        record_get_arguments = {"cors_origins": mock.sentinel.record_get_cors_origin}  # <<

        viewset = ViewSet(
            default_arguments=default_arguments,
            default_record_arguments=default_record_arguments,
            record_get_arguments=record_get_arguments,
        )

        viewset.responses = mock.MagicMock()
        arguments = viewset.record_arguments(mock.MagicMock(), "get")

        self.assertDictEqual(
            arguments,
            {
                "schema": mocked().bind(),
                "cors_headers": mock.sentinel.default_cors_headers,
                "error_handler": mock.sentinel.default_record_error_handler,
                "cors_origins": mock.sentinel.record_get_cors_origin,
                "validators": [colander_validator],
                "response_schemas": viewset.responses.get_and_bind(),
            },
        )
开发者ID:pombredanne,项目名称:kinto,代码行数:38,代码来源:test_viewset.py

示例6: test_schema_is_added_when_uppercase_method_matches

# 需要导入模块: from kinto.core.resource import ViewSet [as 别名]
# 或者: from kinto.core.resource.ViewSet import responses [as 别名]
 def test_schema_is_added_when_uppercase_method_matches(self):
     viewset = ViewSet(collection_methods=("GET", "DELETE"))
     viewset.responses = mock.MagicMock()
     arguments = viewset.collection_arguments(mock.MagicMock(), "get")
     self.assertIn("schema", arguments)
开发者ID:pombredanne,项目名称:kinto,代码行数:7,代码来源:test_viewset.py

示例7: test_schema_is_added_when_method_matches

# 需要导入模块: from kinto.core.resource import ViewSet [as 别名]
# 或者: from kinto.core.resource.ViewSet import responses [as 别名]
 def test_schema_is_added_when_method_matches(self):
     viewset = ViewSet()
     viewset.responses = mock.MagicMock()
     resource = mock.MagicMock()
     arguments = viewset.collection_arguments(resource, "GET")
     self.assertIn("schema", arguments)
开发者ID:pombredanne,项目名称:kinto,代码行数:8,代码来源:test_viewset.py

示例8: test_permission_private_is_set_by_default

# 需要导入模块: from kinto.core.resource import ViewSet [as 别名]
# 或者: from kinto.core.resource.ViewSet import responses [as 别名]
 def test_permission_private_is_set_by_default(self):
     viewset = ViewSet()
     viewset.responses = mock.MagicMock()
     args = viewset.collection_arguments(mock.MagicMock(), "GET")
     self.assertEqual(args["permission"], "private")
开发者ID:pombredanne,项目名称:kinto,代码行数:7,代码来源:test_viewset.py


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