本文整理汇总了Python中mockito.any_value函数的典型用法代码示例。如果您正苦于以下问题:Python any_value函数的具体用法?Python any_value怎么用?Python any_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了any_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_should_return_empty_list_when_no_packages_in_repository
def test_should_return_empty_list_when_no_packages_in_repository(self):
when(RepoContentService).list_architectures(any_value()).thenReturn([])
actual_packages = self.service.list_packages("testrepo")
self.assertEqual([], actual_packages)
verify(RepoContentService).list_architectures(any_value())
示例2: test_should_return_value_of_check
def test_should_return_value_of_check(self):
when(self.git_client).check_if_is_executable(any_value(), any_value()).thenReturn('value from check')
actual_return_value = self.git_client.is_executable()
self.assertEqual('value from check', actual_return_value)
verify(self.git_client).check_if_is_executable('git', '--version')
示例3: test_should_return_empty_dictionary_when_repository_is_empty_but_directory_contains_file
def test_should_return_empty_dictionary_when_repository_is_empty_but_directory_contains_file(self):
repository_path="/path/to/repository"
repository = "testrepo"
architecture1 = "arch1"
architecture2 = "arch2"
architecture3 = "arch3"
tags_file = "tags.txt"
when(RepoConfigService).getStaticRepoDir(any_value()).thenReturn(repository_path)
when(yum_repo_server.api.services.repoContentService.os).listdir(any_value()).thenReturn([architecture1, architecture2, architecture3, tags_file]).thenReturn([])
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture1)).thenReturn(True)
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture2)).thenReturn(True)
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture3)).thenReturn(True)
when(yum_repo_server.api.services.repoContentService.os.path).isdir(tags_file).thenReturn(False)
actual_architectures = self.service.list_architectures(repository)
self.assertEqual([], actual_architectures)
verify(RepoConfigService).getStaticRepoDir(repository)
verify(yum_repo_server.api.services.repoContentService.os).listdir(repository_path)
verify(yum_repo_server.api.services.repoContentService.os).listdir(os.path.join(repository_path, architecture1))
verify(yum_repo_server.api.services.repoContentService.os).listdir(os.path.join(repository_path, architecture2))
verify(yum_repo_server.api.services.repoContentService.os).listdir(os.path.join(repository_path, architecture3))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture1))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture2))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture3))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, tags_file))
verify(yum_repo_server.api.services.repoContentService.os, never).listdir(os.path.join(repository_path, tags_file))
示例4: test_run_should_exit_with_error_when_non_existing_file_is_given
def test_run_should_exit_with_error_when_non_existing_file_is_given(self):
mock_when(yadt_lint)._get_configuration(any_value()).thenRaise(IOError)
mock_when(yadt_lint.sys).exit(any_value()).thenReturn(None)
yadt_lint._validate_yaml_input(IOError)
verify(yadt_lint.sys).exit(1)
示例5: test_should_return_empty_dictionary_even_if_meta_data_has_been_generated
def test_should_return_empty_dictionary_even_if_meta_data_has_been_generated(self):
repository_path="/path/to/repository"
repository = "testrepo"
architecture1 = "arch1"
architecture2 = "arch2"
repodata_directory = "repodata"
metadata_xml_file = "repomd.xml"
when(RepoConfigService).getStaticRepoDir(any_value()).thenReturn(repository_path)
when(yum_repo_server.api.services.repoContentService.os).listdir(any_value()).thenReturn([architecture1, architecture2, repodata_directory, metadata_xml_file]).thenReturn([])
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture1)).thenReturn(True)
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture2)).thenReturn(True)
when(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, repodata_directory)).thenReturn(True)
actual_architectures = self.service.list_architectures(repository)
self.assertEqual([], actual_architectures)
verify(RepoConfigService).getStaticRepoDir(repository)
verify(yum_repo_server.api.services.repoContentService.os).listdir(repository_path)
verify(yum_repo_server.api.services.repoContentService.os).listdir(os.path.join(repository_path, architecture1))
verify(yum_repo_server.api.services.repoContentService.os).listdir(os.path.join(repository_path, architecture2))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture1))
verify(yum_repo_server.api.services.repoContentService.os.path).isdir(os.path.join(repository_path, architecture2))
verify(yum_repo_server.api.services.repoContentService.os.path, never).isdir(os.path.join(repository_path, repodata_directory))
示例6: test_should_create_destination_directories_when_propagating_repository
def test_should_create_destination_directories_when_propagating_repository(self):
destination_repository_path = "destination-static-repository-path"
destination_repository = "destination-repo"
destination_path1 = os.path.join(destination_repository_path, "arch1")
destination_path2 = os.path.join(destination_repository_path, "arch2")
package_path1 = os.path.join("source-repository-path", "arch1", "spam.rpm")
package_path2 = os.path.join("source-repository-path", "arch2", "egg.rpm")
when(RepoConfigService).determine_static_repository_path(destination_repository).thenReturn(destination_repository_path)
when(RepoContentService).list_packages(any_value()).thenReturn([package_path1, package_path2])
when(yum_repo_server.api.services.repoPropagationService.shutil).move(any_value(), any_value()).thenReturn(None)
when(yum_repo_server.api.services.repoPropagationService.os.path).exists(any_value()).thenReturn(False)
when(yum_repo_server.api.services.repoPropagationService.os).makedirs(any_value()).thenReturn(None)
self.service.propagate_repository("source-repo", destination_repository)
verify(RepoConfigService).determine_static_repository_path(destination_repository)
verify(RepoContentService).list_packages("source-repo")
verify(yum_repo_server.api.services.repoPropagationService.os.path).exists(destination_path1)
verify(yum_repo_server.api.services.repoPropagationService.os).makedirs(destination_path1)
verify(yum_repo_server.api.services.repoPropagationService.shutil).move(package_path1, destination_path1)
verify(yum_repo_server.api.services.repoPropagationService.os.path).exists(destination_path2)
verify(yum_repo_server.api.services.repoPropagationService.os).makedirs(destination_path2)
verify(yum_repo_server.api.services.repoPropagationService.shutil).move(package_path2, destination_path2)
示例7: setUp
def setUp(self):
self.project = Project("unittest", ".")
self.project.set_property("dir_install_logs", "any_directory")
self.logger = mock(Logger)
when(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
any_value(), any_value(), shell=True
).thenReturn(0)
示例8: test_should_install_requirements_file_dependency
def test_should_install_requirements_file_dependency(self):
dependency = RequirementsFile("requirements.txt")
install_dependency(self.logger, self.project, dependency)
verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
[PIP_EXECUTABLE, "install", '-r', "requirements.txt"], any_value(), env=any_value(), shell=False)
示例9: test_should_propagate_package_using_rpm_service
def test_should_propagate_package_using_rpm_service(self):
package_name = "package_name"
architecture = "architecture"
source_repository_name = "source-repository-name"
source_path = "source-static-repository-path"
destination_repository_name = "destination-repository-name"
destination_path = "destination-static-repository-path"
when(RepoConfigService).determine_static_repository_path(source_repository_name).thenReturn(source_path)
when(RepoConfigService).determine_static_repository_path(destination_repository_name).thenReturn(destination_path)
when(yum_repo_server.api.services.repoPropagationService.os.path).exists(any_value()).thenReturn(True)
when(yum_repo_server.api.services.repoPropagationService).create_rpm_file_object(any_value()).thenReturn(True)
when(yum_repo_server.api.services.repoPropagationService.shutil).move(any_value(), any_value()).thenReturn(None)
actual_file_name = self.service.propagatePackage(package_name, source_repository_name, destination_repository_name, architecture)
self.assertEqual(package_name, actual_file_name)
verify(RepoConfigService).determine_static_repository_path(source_repository_name)
verify(RepoConfigService).determine_static_repository_path(destination_repository_name)
verify(yum_repo_server.api.services.repoPropagationService).create_rpm_file_object(package_name)
source_rpm_path = os.path.join(source_path, architecture, package_name)
destination_rpm_parent_dir = os.path.join(destination_path, architecture)
destination_rpm_path = os.path.join(destination_rpm_parent_dir, package_name)
verify(yum_repo_server.api.services.repoPropagationService.os.path).exists(source_rpm_path)
verify(yum_repo_server.api.services.repoPropagationService.os.path).exists(destination_rpm_parent_dir)
verify(yum_repo_server.api.services.repoPropagationService.shutil).move(source_rpm_path, destination_rpm_path)
示例10: test_should_install_dependency_without_version
def test_should_install_dependency_without_version(self):
dependency = Dependency("spam")
install_dependency(self.logger, self.project, dependency)
verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
[PIP_EXECUTABLE, "install", 'spam'], any_value(), env=any_value(), shell=False)
示例11: test_should_install_dependency_with_version_and_operator
def test_should_install_dependency_with_version_and_operator(self):
dependency = Dependency("spam", "==0.1.2")
install_dependency(self.logger, self.project, dependency)
verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
PIP_EXEC_STANZA + ["install", 'spam==0.1.2'], any_value(), env=any_value(), shell=False)
示例12: ensure_that_get_package_content_checks_if_package_is_hosted
def ensure_that_get_package_content_checks_if_package_is_hosted():
pypiproxy.services._hosted_packages_index = mock()
when(pypiproxy.services._hosted_packages_index).contains(any_value(), any_value()).thenReturn(True)
pypiproxy.services.get_package_content("spam", "0.1.1")
verify(pypiproxy.services._hosted_packages_index).contains("spam", "0.1.1")
示例13: test_should_install_dependency_without_version_on_windows_derivate
def test_should_install_dependency_without_version_on_windows_derivate(self):
dependency = Dependency("spam")
install_dependency(self.logger, self.project, dependency)
verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
PIP_EXEC_STANZA + ["install", "spam"], any_value(), env=any_value(), shell=False)
示例14: test_should_prepend_hg_to_given_arguments
def test_should_prepend_hg_to_given_arguments (self):
when(self.mercurial_client)._hg(any_value(), any_value(), any_value()).thenReturn(None)
when(self.mercurial_client)._hg(any_value()).thenReturn(None)
self.mercurial_client.commit('This is a commit message.')
verify(self.mercurial_client)._hg('commit', '-m', 'This is a commit message.')
verify(self.mercurial_client)._hg('push')
示例15: test_should_perform_command_and_receive_ok
def test_should_perform_command_and_receive_ok(self):
mock_socket = mock()
when(livestatus_service.livestatus.time).time().thenReturn(123)
when(livestatus_service.livestatus.socket).socket(any_value(), any_value()).thenReturn(mock_socket)
perform_command('foobar', '/path/to/socket')
verify(mock_socket).send(b'COMMAND [123] foobar\n')