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


Python MagicMock.QUERY_PARAMS方法代码示例

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


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

示例1: test_parse_int_list

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
    def test_parse_int_list(self):
        '''Tests parsing a required list of int parameters that is provided via GET.'''
        request = MagicMock(Request)
        request.QUERY_PARAMS = QueryDict('', mutable=True)
        request.QUERY_PARAMS.setlist('test', ['1', '2'])

        self.assertListEqual(rest_util.parse_int_list(request, 'test'), [1, 2])
开发者ID:dev-geo,项目名称:scale,代码行数:9,代码来源:test_rest.py

示例2: test_parse_int_list_accepted_all

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
    def test_parse_int_list_accepted_all(self):
        '''Tests parsing a list of int parameters where all values are acceptable.'''
        request = MagicMock(Request)
        request.QUERY_PARAMS = QueryDict('', mutable=True)
        request.QUERY_PARAMS.setlist('test', ['1', '2'])

        self.assertListEqual(rest_util.parse_int_list(request, 'test', accepted_values=[1, 2]), [1, 2])
开发者ID:dev-geo,项目名称:scale,代码行数:9,代码来源:test_rest.py

示例3: test_parse_string_list_default

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
    def test_parse_string_list_default(self):
        '''Tests parsing a required list of string parameters that are provided via default value.'''
        request = MagicMock(Request)
        request.QUERY_PARAMS = QueryDict('', mutable=True)
        request.QUERY_PARAMS.setlist('test', ['value1'])

        self.assertEqual(rest_util.parse_string_list(request, 'test2', ['value2', 'value3']), ['value2', 'value3'])
开发者ID:dev-geo,项目名称:scale,代码行数:9,代码来源:test_rest.py

示例4: test_parse_string_list_missing

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
    def test_parse_string_list_missing(self):
        '''Tests parsing a required list of string parameters that are missing.'''
        request = MagicMock(Request)
        request.QUERY_PARAMS = QueryDict('', mutable=True)
        request.QUERY_PARAMS.setlist('test', ['value1', 'value2'])

        self.assertRaises(BadParameter, rest_util.parse_string_list, request, 'test2')
开发者ID:dev-geo,项目名称:scale,代码行数:9,代码来源:test_rest.py

示例5: test_parse_string_list_accepted_none

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
    def test_parse_string_list_accepted_none(self):
        '''Tests parsing a list of string parameters where none of the values are acceptable.'''
        request = MagicMock(Request)
        request.QUERY_PARAMS = QueryDict('', mutable=True)
        request.QUERY_PARAMS.setlist('test', ['value1', 'value2'])

        self.assertRaises(BadParameter, rest_util.parse_string_list, request, 'test', accepted_values=['value'])
开发者ID:dev-geo,项目名称:scale,代码行数:9,代码来源:test_rest.py

示例6: test_parse_string_list_optional

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
    def test_parse_string_list_optional(self):
        '''Tests parsing an optional list of string parameters that are missing.'''
        request = MagicMock(Request)
        request.QUERY_PARAMS = QueryDict('', mutable=True)
        request.QUERY_PARAMS.setlist('test', ['value1'])

        self.assertListEqual(rest_util.parse_string_list(request, 'test2', required=False), [])
开发者ID:dev-geo,项目名称:scale,代码行数:9,代码来源:test_rest.py

示例7: test_parse_int_list_accepted_partial

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
    def test_parse_int_list_accepted_partial(self):
        '''Tests parsing a list of int parameters where only some values are acceptable.'''
        request = MagicMock(Request)
        request.QUERY_PARAMS = QueryDict('', mutable=True)
        request.QUERY_PARAMS.setlist('test', ['1', '2'])

        self.assertRaises(BadParameter, rest_util.parse_int_list, request, 'test', accepted_values=[1])
开发者ID:dev-geo,项目名称:scale,代码行数:9,代码来源:test_rest.py

示例8: test_parse_string_default

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
 def test_parse_string_default(self):
     '''Tests parsing an optional string parameter that is provided via default value.'''
     request = MagicMock(Request)
     request.QUERY_PARAMS = QueryDict('', mutable=True)
     request.QUERY_PARAMS.update({
         'test': 'value1',
     })
     self.assertEqual(rest_util.parse_string(request, 'test2', 'value2'), 'value2')
开发者ID:dev-geo,项目名称:scale,代码行数:10,代码来源:test_rest.py

示例9: test_parse_datetime_missing_timezone

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
 def test_parse_datetime_missing_timezone(self):
     '''Tests parsing an ISO datetime missing a timezone.'''
     request = MagicMock(Request)
     request.QUERY_PARAMS = QueryDict('', mutable=True)
     request.QUERY_PARAMS.update({
         'test': '2015-01-01T00:00:00',
     })
     self.assertRaises(BadParameter, rest_util.parse_datetime, request, 'test')
开发者ID:dev-geo,项目名称:scale,代码行数:10,代码来源:test_rest.py

示例10: test_parse_datetime_optional

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
 def test_parse_datetime_optional(self):
     '''Tests parsing an optional ISO datetime parameter that is missing.'''
     request = MagicMock(Request)
     request.QUERY_PARAMS = QueryDict('', mutable=True)
     request.QUERY_PARAMS.update({
         'test': 'value1',
     })
     self.assertIsNone(rest_util.parse_datetime(request, 'test2', required=False))
开发者ID:dev-geo,项目名称:scale,代码行数:10,代码来源:test_rest.py

示例11: test_parse_datetime_missing

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
 def test_parse_datetime_missing(self):
     '''Tests parsing a required ISO datetime parameter that is missing.'''
     request = MagicMock(Request)
     request.QUERY_PARAMS = QueryDict('', mutable=True)
     request.QUERY_PARAMS.update({
         'test': '10',
     })
     self.assertRaises(BadParameter, rest_util.parse_datetime, request, 'test2')
开发者ID:dev-geo,项目名称:scale,代码行数:10,代码来源:test_rest.py

示例12: test_parse_float_invalid

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
 def test_parse_float_invalid(self):
     '''Tests parsing a required float parameter that is not a valid number.'''
     request = MagicMock(Request)
     request.QUERY_PARAMS = QueryDict('', mutable=True)
     request.QUERY_PARAMS.update({
         'test': 'abc',
     })
     self.assertRaises(BadParameter, rest_util.parse_float, request, 'test')
开发者ID:dev-geo,项目名称:scale,代码行数:10,代码来源:test_rest.py

示例13: test_parse_duration

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
 def test_parse_duration(self):
     '''Tests parsing a required ISO duration parameter that is provided via GET.'''
     request = MagicMock(Request)
     request.QUERY_PARAMS = QueryDict('', mutable=True)
     request.QUERY_PARAMS.update({
         'test': 'PT3H0M0S',
     })
     self.assertEqual(rest_util.parse_duration(request, 'test'), datetime.timedelta(0, 10800))
开发者ID:dev-geo,项目名称:scale,代码行数:10,代码来源:test_rest.py

示例14: test_parse_bool_default

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
 def test_parse_bool_default(self):
     '''Tests parsing an optional bool parameter that is provided via default value.'''
     request = MagicMock(Request)
     request.QUERY_PARAMS = QueryDict('', mutable=True)
     request.QUERY_PARAMS.update({
         'test': 'true',
     })
     self.assertFalse(rest_util.parse_bool(request, 'test2', False))
开发者ID:dev-geo,项目名称:scale,代码行数:10,代码来源:test_rest.py

示例15: test_parse_float_zero

# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import QUERY_PARAMS [as 别名]
 def test_parse_float_zero(self):
     '''Tests parsing an optional float parameter zero instead of using the default value.'''
     request = MagicMock(Request)
     request.QUERY_PARAMS = QueryDict('', mutable=True)
     request.QUERY_PARAMS.update({
         'test': '0.0',
     })
     self.assertEqual(rest_util.parse_float(request, 'test', 10.1), 0.0)
开发者ID:dev-geo,项目名称:scale,代码行数:10,代码来源:test_rest.py


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