本文整理汇总了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(),
},
)
示例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)
示例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()
示例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(),
},
)
示例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(),
},
)
示例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)
示例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)
示例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")