本文整理汇总了Python中mock.Mock.path方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.path方法的具体用法?Python Mock.path怎么用?Python Mock.path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.Mock
的用法示例。
在下文中一共展示了Mock.path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_should_not_include_files_outside_config_directory
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def test_should_not_include_files_outside_config_directory(self):
mock_svn_service = Mock(SvnService)
mock_svn_service.config_url = 'svn://url/for/configuration/repository'
mock_svn_service.path_to_config = '/config'
mock_svn_service.client = Mock()
mock_info = Mock()
mock_path_object_1 = Mock()
mock_path_object_1.path = '/config/foo'
mock_path_object_1.action = 'A'
mock_path_object_2 = Mock()
mock_path_object_2.path = '/XXXXXX/bar'
mock_path_object_2.action = 'A'
mock_path_object_3 = Mock()
mock_path_object_3.path = '/XXX/foobar'
mock_path_object_3.action = 'A'
mock_info.changed_paths = [mock_path_object_1, mock_path_object_2, mock_path_object_3]
mock_svn_service.get_logs_for_revision.return_value = [mock_info]
actual = SvnService.get_changed_paths_with_action(mock_svn_service, '1980')
self.assertEqual([('foo', 'A')], actual)
示例2: _given_dst_has_files
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def _given_dst_has_files(self):
name1 = "src1"
name2 = "src2"
url1 = Mock()
url1.path = name1
url2 = Mock()
url2.path = name2
self._dst.list.return_value = [url1, url2]
return [name1, name2]
示例3: test_remove_duplicates
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def test_remove_duplicates(self):
self.assertEqual([], remove_duplicates([]))
issue1 = Mock()
issue2 = Mock()
issue1.path = '/filename'
issue2.path = '/filename'
issue1.severity = 10
issue2.severity = 10
issue1.line_number_start = None
issue2.line_number_start = None
issue1.line_position = None
issue2.line_position = None
issue1.message = 'foo'
issue2.message = 'bar'
self.assertEqual([issue1, issue2], remove_duplicates([issue1, issue2]))
issue1.line_number_start = 42
issue2.line_number_start = 42
issue1.message = 'line too long'
issue2.message = 'unused import foo'
self.assertEqual([issue1, issue2], remove_duplicates([issue1, issue2]))
issue1.line_number_start = 42
issue2.line_number_start = 42
issue1.line_position = -1
issue2.line_position = -1
issue1.message = 'unused import bar'
issue2.message = 'module bar not used'
self.assertEqual([issue1], remove_duplicates([issue1, issue2]))
issue1.line_number_start = 42
issue2.line_number_start = 42
issue1.line_position = 12
issue2.line_position = 28
issue1.message = 'unused import bar'
issue2.message = 'module foo not used'
self.assertEqual([issue1, issue2], remove_duplicates([issue1, issue2]))
issue1.line_number_start = 32
issue2.line_number_start = 32
issue1.line_position = 80
issue2.line_position = -1
issue1.message = 'line too long (92 characters)'
issue2.message = 'Line too long (92/80)'
self.assertEqual([issue1], remove_duplicates([issue1, issue2]))
issue1.line_number_start = 32
issue2.line_number_start = 33
issue1.line_position = 80
issue2.line_position = -1
issue1.message = 'line too long (92 characters)'
issue2.message = 'Line too long (92/80)'
self.assertEqual([issue1, issue2], remove_duplicates([issue1, issue2]))
示例4: default_args
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def default_args():
args = Mock()
args.conf_file = '.lamvery.yml'
args.path = 'requirements.txt'
args.file = 'bar.txt'
args.store = False
return args
示例5: _get_mock_page
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def _get_mock_page(path='mock', depth=0, parent=None):
mock_page = Mock()
mock_page.path = path
mock_page.save.return_value = True
mock_page.parent = parent
mock_page.children = _get_children_mock(depth, parent=mock_page)
return mock_page
示例6: test_find_all_markdown_in_shallow_repo
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def test_find_all_markdown_in_shallow_repo(exists):
"DocumentIndexer#find_all_markdown_files() in a folder with no child nodes"
origin = '/foo/bar'
maker = DocumentIndexer(origin)
maker.node = Mock(path='/weeee')
maker.node.relative.side_effect = lambda x: "relative[{0}]".format(x)
markdown_node = Mock()
markdown_node.dir.path = '/ccc/aaa'
markdown_node.path = '/FFF/000'
maker.node.grep.return_value = [markdown_node]
files = list(maker.find_all_markdown_files())
files.should.equal([{
u'path': u'/ccc/aaa',
u'type': u'tree',
u'relative_path': u'relative[/ccc/aaa]'
},
{
u'path': u'/FFF/000',
u'type': u'blob',
u'relative_path': u'relative[/FFF/000]'
}
])
repr(maker).should.equal('<markment.fs.DocumentIndexer(path=/weeee)>')
示例7: test_api_resource
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def test_api_resource():
"""
Test APIResource class
"""
resource = pdrest.APIResource()
resource.register("method", "method", do_nothing)
request = Mock()
request.method = "method"
request.path = "method"
result = resource._get_callback(request)
assert result[0] == do_nothing
resource.getChild("method", request)
resource.unregister(regex="method")
# After unregister, the callback should be gone.
result = resource._get_callback(request)
assert result[0] is None
resource.getChild("method", request)
resource.children = Mock(name="what")
result = resource.getChild("method", request)
resource.getChild("method", request)
示例8: test_owner_or_mod_required_passes_url_parameters
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def test_owner_or_mod_required_passes_url_parameters(self):
@owner_or_moderator_required
def mock_view(request, user, context):
return None
request = Mock(spec=('path', 'REQUEST', 'user'))
request.user = AnonymousUser()
request.REQUEST = {'abra': 'cadabra', 'foo': 'bar'}
request.path = '/some/path/'
user = self.create_user('user')
response = mock_view(request, user, {})
self.assertEqual(isinstance(response, HttpResponseRedirect), True)
url = response['location']
parsed_url = urlparse.urlparse(url)
self.assertEqual(parsed_url.path, reverse('user_signin'))
next = dict(urlparse.parse_qsl(parsed_url.query))['next']
next_url = urllib.unquote(next)
parsed_url = urlparse.urlparse(next_url)
self.assertEqual(parsed_url.path, request.path)
query = dict(urlparse.parse_qsl(parsed_url.query))
self.assertEqual(set(query.keys()), set(['foo', 'abra']))
self.assertEqual(set(query.values()), set(['bar', 'cadabra']))
self.assertEqual(query['abra'], 'cadabra')
示例9: create_mock_text_editor
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def create_mock_text_editor(content):
"""
:param str content: Fake edits to return
"""
mock = Mock(spec=TextEditor)
mock.edit.return_value = content
mock.path = None
return mock
示例10: test_get_path
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def test_get_path(self):
request = Mock()
request.path = '/v2/recordsets'
recordset = Mock()
recordset.zone_id = 'a-b-c-d'
expected_path = '/v2/zones/a-b-c-d/recordsets'
path = adapters.RecordSetAPIv2Adapter._get_path(request, recordset)
self.assertEqual(expected_path, path)
示例11: create_mock
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def create_mock(name, build_depends, run_depends, path):
m = Mock()
m.name = name
m.build_depends = build_depends
m.buildtool_depends = []
m.run_depends = run_depends
m.exports = []
m.path = path
return m
示例12: test_no_long_url
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def test_no_long_url(self):
url = '1234567890' * 19 # 190-character URL
mock_request = Mock()
mock_request.META = {'CONTENT_TYPE': 'text/plain'}
mock_request.GET = {}
mock_request.path = url
mock_request.method = 'get'
request_model = RequestModelFactory(mock_request).construct_request_model()
self.assertEqual(request_model.path, url)
示例13: test_max_request
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def test_max_request(self):
SilkyConfig().SILKY_MAX_REQUEST_BODY_SIZE = 10 # 10kb
mock_request = Mock()
mock_request.META = {"CONTENT_TYPE": "text/plain"}
mock_request.GET = {}
mock_request.body = "a".encode("ascii") * 1024 * 100 # 100kb
mock_request.path = reverse("silk:requests")
request_model = RequestModelFactory(mock_request).construct_request_model()
self.assertFalse(request_model.raw_body)
示例14: create_mock
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def create_mock(name, builddeps, path):
m = Mock()
m.name = name
m.builddeps = builddeps
m.buildtooldeps = []
m.rundeps = []
m.exports = []
m.path = path
return m
示例15: test_anonymous_user_access_to_page_without_group
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import path [as 别名]
def test_anonymous_user_access_to_page_without_group(self):
"""
Test that method 'process_request' of PageAuthMiddleware middleware
return None if user of request is an 'AnonymousUser' and the request
page don't have groups associated.
"""
mock_request = Mock()
mock_request.user = AnonymousUser()
mock_request.path = self.pages_no_group[0].slug
self.assertIsNone(self.middlware.process_request(mock_request))