def test_should_propagate_repository_with_one_package(self): architecture = "arch1" destination_path = "destination-static-repository-path" destination_repository = "destination-repo" package_path = os.path.join("source-repository-path", architecture, "spam.rpm") when(RepoPropagationService).determine_repository_path( destination_repository).thenReturn(destination_path) when(RepoContentService).list_packages(any_value()).thenReturn( [package_path]) 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(True) self.service.propagate_repository("source-repo", destination_repository) verify(RepoPropagationService).determine_repository_path( destination_repository) verify(RepoContentService).list_packages("source-repo") destination_path = os.path.join(destination_path, architecture) verify(yum_repo_server.api.services.repoPropagationService.os.path ).exists(destination_path) verify( yum_repo_server.api.services.repoPropagationService.shutil).move( package_path, destination_path)
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)
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)
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))
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)
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")
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())
def test_should_run_all_tasks_until_finished(self): when(pyb_init).docopt(doc=any_value(), version=any_value()).thenReturn({ 'local': True, 'github': False, 'git': False, 'svn': False, '--virtualenv': 'virtualenv' }) mock_reactor = mock() mock_task_1 = mock() mock_task_2 = mock() when(pyb_init.reactor).for_local_initialization().thenReturn( mock_reactor) when(mock_reactor).get_tasks().thenReturn([mock_task_1, mock_task_2]) entry_point() verify(mock_task_1).execute() verify(mock_task_2).execute()
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')
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)
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)
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))
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)
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)
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)
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)
def test_should_install_multiple_dependencies_locally(self): self.project.depends_on("spam") self.project.depends_on("eggs") self.project.depends_on("foo") self.project.set_property("install_dependencies_local_mapping", { "spam": "any-dir", "eggs": "any-other-dir" }) install_runtime_dependencies(self.logger, self.project) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command( [PIP_EXECUTABLE, "install", "-t", "any-dir", 'spam'], any_value(), shell=False) verify( pybuilder.plugins.python.install_dependencies_plugin ).execute_command( [PIP_EXECUTABLE, "install", "-t", "any-other-dir", 'eggs'], any_value(), shell=False) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command([PIP_EXECUTABLE, "install", 'foo'], any_value(), shell=False)
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')
def test_should_upgrade_dependencies(self): self.project.set_property("install_dependencies_upgrade", True) dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command( PIP_EXEC_STANZA + ["install", "--upgrade", 'spam'], any_value(), env=any_value(), shell=False)
def test_should_raise_exception_when_shell_call_fails(self): when(pyb_init.tasks.subprocess).call(any_value(), stderr=any_value(), stdout=any_value(), shell=any_value()).thenReturn(5) task = ShellCommandTask('ls -l') self.assertRaises(ShellCommandTaskException, task.execute)
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')
def should_send_not_found_when_trying_to_get_package_content_for_nonexisting_package(web_application): when(webapp).get_package_content(any_value(), any_value()).thenReturn(None) response = web_application.get("/package/package_name/version/package_name-version.tar.gz") assert_that(response.status_code).is_equal_to(404) verify(webapp).get_package_content("package_name", "version")
def test_should_not_use_extra_index_url_when_index_url_is_not_set(self): self.project.set_property("install_dependencies_extra_index_url", "some_index_url") 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)
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")
def test_run_should_exit_with_error_when_target_yaml_parsing_fails(self): problem_mark = Mark('name', 1, 2, 3, '', '') mock_when(yadt_lint)._get_configuration(any_value()).thenRaise(ScannerError(problem_mark=problem_mark)) mock_when(yadt_lint.sys).exit(any_value()).thenReturn(None) yadt_lint._validate_yaml_input(problem_mark) verify(yadt_lint.sys).exit(1) verify(yadt_lint.logger).error('Invalid YAML Format check position: (line:column) -> (2:4)')
def test_should_return_stdout_and_stderr_from_execution(self): stdout = 'stdout' stderr = 'stderr' when(self.git_client).execute_command(any_value(), any_value(), any_value(), any_value()).thenReturn((stdout, stderr)) actual_stdout, actual_stderr = self.git_client._git('arg1', 'arg2', 'arg3') self.assertEqual(stdout, actual_stdout) self.assertEqual(stderr, actual_stderr)
def test_should_not_use_insecure_flags_when_pip_version_is_too_low(self): dependency = Dependency("spam") self.project.set_property("install_dependencies_insecure_installation", ["spam"]) when(pybuilder.pip_utils)._pip_disallows_insecure_packages_by_default().thenReturn(False) 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)
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')
def test_should_raise_exception_when_repository_directory_does_not_exist(self): service = RepoConfigService() when(service).getStaticRepoDir(any_value()).thenReturn("path/to/repository") when(yum_repo_server.api.services.repoConfigService.os.path).exists(any_value()).thenReturn(False) self.assertRaises(Exception, service.determine_static_repository_path, ()) unstub()
def test_perform_command_should_dispatch_to_icinga_if_handler_is_icinga(self): when(livestatus_service.dispatcher).perform_icinga_command(any_value(), any_value(), any_value()).thenReturn(None) mock_config = mock() mock_config.icinga_command_file = '/path/to/commandfile.cmd' when(livestatus_service.dispatcher).get_current_configuration().thenReturn(mock_config) perform_command('FOO;bar', None, 'icinga') verify(livestatus_service.dispatcher).perform_icinga_command('FOO;bar', '/path/to/commandfile.cmd', None)
def test_perform_query_should_dispatch_to_livestatus_if_handler_is_livestatus(self): when(livestatus_service.dispatcher).perform_livestatus_query(any_value(), any_value(), any_value()).thenReturn(None) mock_config = mock() mock_config.livestatus_socket = '/path/to/socket' when(livestatus_service.dispatcher).get_current_configuration().thenReturn(mock_config) perform_query('FOO;bar', None, 'livestatus') verify(livestatus_service.dispatcher).perform_livestatus_query('FOO;bar', '/path/to/socket', None)
def test_should_return_empty_dictionary_when_no_architectures_in_repository(self): when(yum_repo_server.api.services.repoContentService.os).listdir(any_value()).thenReturn([]) when(RepoConfigService).getStaticRepoDir(any_value()).thenReturn("/path/to/repository") actual_architectures = self.service.list_architectures("testrepo") self.assertEqual([], actual_architectures) verify(RepoConfigService).getStaticRepoDir("testrepo") verify(yum_repo_server.api.services.repoContentService.os).listdir("/path/to/repository")
def should_send_ok_and_delegate_to_services_when_uploading_file(web_application): when(webapp).add_package(any_value(), any_value(), any_value()).thenReturn(None) response = web_application.post("/", data={":action": "file_upload", "name": "name", "version": "version", "content": (StringIO.StringIO("content"), "name-version.tar.gz")}) assert_that(response.status_code).is_equal_to(200) verify(webapp).add_package("name", "version", "content")
def should_send_not_found_when_trying_to_get_package_content_for_nonexisting_package( web_application): when(webapp).get_package_content(any_value(), any_value()).thenReturn(None) response = web_application.get( "/package/package_name/version/package_name-version.tar.gz") assert_that(response.status_code).is_equal_to(404) verify(webapp).get_package_content("package_name", "version")
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)
def test_should_return_two_packages_from_one_architecture_directory(self): when(RepoContentService).list_architectures(any_value()).thenReturn(["/path/to/repository/architecture"]) when(yum_repo_server.api.services.repoContentService.os).listdir(any_value()).thenReturn(["spam.rpm", "egg.rpm"]) actual_packages = self.service.list_packages("testrepo") self.assertEqual(["/path/to/repository/architecture/spam.rpm", "/path/to/repository/architecture/egg.rpm"], actual_packages) verify(yum_repo_server.api.services.repoContentService.os).listdir("/path/to/repository/architecture")
def ensure_that_get_package_content_delegates_to_hosted_packages_index(): pypiproxy.services._hosted_packages_index = mock() package_content = mock() when(pypiproxy.services._hosted_packages_index).get_package_content(any_value(), any_value()).thenReturn(package_content) when(pypiproxy.services._hosted_packages_index).contains(any_value(), any_value()).thenReturn(True) actual_content = pypiproxy.services.get_package_content("spam", "0.1.1") assert_that(actual_content).is_equal_to(package_content) verify(pypiproxy.services._hosted_packages_index).get_package_content("spam", "0.1.1")
def test_should_install_dependency_securely_when_property_is_not_set_to_dependency(self): dependency = Dependency("spam") self.project.set_property("install_dependencies_insecure_installation", ["some-other-dependency"]) when(pybuilder.pip_utils)._pip_disallows_insecure_packages_by_default().thenReturn(True) install_dependency(self.logger, self.project, dependency) verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command( PIP_EXEC_STANZA + ["install", "--allow-unverified", "some-other-dependency", "--allow-external", "some-other-dependency", 'spam'], any_value(), env=any_value(), shell=False)
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)
def test_should_install_single_dependency_without_version(self): self.project.depends_on("spam") self.project.build_depends_on("eggs") install_dependencies(self.logger, self.project) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command("pip install 'spam'", any_value(), shell=True) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command("pip install 'eggs'", any_value(), shell=True)
def test_should_install_single_dependency_without_version(self): self.project.depends_on("spam") self.project.build_depends_on("eggs") install_dependencies(self.logger, self.project) verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command( PIP_EXEC_STANZA + ["install", 'spam'], any_value(), shell=False) verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command( PIP_EXEC_STANZA + ["install", 'eggs'], any_value(), shell=False)
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)
def ensure_proxy_checks_if_package_is_already_cached(temp_dir): temp_dir.create_directory("packages") proxy_package_index = ProxyPackageIndex( "cached", temp_dir.join("packages"), "http://pypi.python.org") proxy_package_index._package_index = mock() when(proxy_package_index._package_index).contains( any_value(), any_value()).thenReturn(True) proxy_package_index.get_package_content("pyassert", "0.2.5") verify(proxy_package_index._package_index).contains("pyassert", "0.2.5")
def test_should_initialize_docopt(self): mock_args = {'<file>': 'target', 'services_validate': False, 'target_validate': True} mock_when(yadt_lint).docopt(any_value(), version=any_value()).thenReturn(mock_args) mock_when(yadt_lint)._get_configuration(any_value()).thenReturn(None) mock_when(yadt_lint)._validate_target_schema_new(any_value()).thenReturn(None) yadt_lint.run() verify(yadt_lint).docopt(yadt_lint.__doc__, version=yadt_lint.__version__)
def set_up_no_op_reactor(self): mock_reactor = mock() when(mock_reactor).get_tasks().thenReturn([]) when(pyb_init.reactor).for_local_initialization().thenReturn( mock_reactor) when(pyb_init.reactor).for_github_clone( user=any_value(), project=any_value()).thenReturn(mock_reactor) when(pyb_init.reactor).for_git_clone( git_url=any_value()).thenReturn(mock_reactor) when(pyb_init.reactor).for_svn_checkout( svn_url=any_value()).thenReturn(mock_reactor)
def test_should_install_dependency_with_url_even_if_version_is_given(self): dependency = Dependency("spam", version="0.1.2", url="some_url") install_dependency(self.logger, self.project, dependency) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command(PIP_EXEC_STANZA + ["install", "--force-reinstall", 'some_url'], any_value(), env=any_value(), shell=False)
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)
def test_should_install_dependency_with_url(self): dependency = Dependency("spam", url="some_url") install_dependency(self.logger, self.project, dependency) verify( pybuilder.plugins.python.install_dependencies_plugin ).execute_command( [PIP_EXECUTABLE, "install", "--force-reinstall", 'some_url'], any_value(), env=any_value(), shell=False)
def test_should_upgrade_dependencies(self): self.project.set_property("install_dependencies_upgrade", True) dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) verify(pybuilder.plugins.python.install_dependencies_plugin ).execute_command( [PIP_EXECUTABLE, "install", "--upgrade", 'spam'], any_value(), env=any_value(), shell=False)
def test_should_not_use_extra_index_url_when_index_url_is_not_set(self): self.project.set_property("install_dependencies_extra_index_url", "some_index_url") 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)
def test_should_exit_when_invalid_targetfile_name_is_given(self): mock_args = {'<file>': 'foobar', 'target_validate': True, 'services_validate': False} mock_when(yadt_lint).docopt(any_value(), version=any_value()).thenReturn(mock_args) mock_when(yadt_lint.sys).exit(any_value()).thenReturn(None) mock_when(yadt_lint)._validate_target_schema_new(any_value()).thenReturn(None) mock_when(yadt_lint)._validate_yaml_input(any_value()).thenReturn(None) yadt_lint.run() verify(yadt_lint.sys).exit(1)
def test_perform_command_should_dispatch_to_icinga_if_handler_is_icinga( self): when(livestatus_service.dispatcher).perform_icinga_command( any_value(), any_value(), any_value()).thenReturn(None) mock_config = mock() mock_config.icinga_command_file = '/path/to/commandfile.cmd' when(livestatus_service.dispatcher).get_current_configuration( ).thenReturn(mock_config) perform_command('FOO;bar', None, 'icinga') verify(livestatus_service.dispatcher).perform_icinga_command( 'FOO;bar', '/path/to/commandfile.cmd', None)
def test_perform_query_should_dispatch_to_livestatus_if_handler_is_livestatus( self): when(livestatus_service.dispatcher).perform_livestatus_query( any_value(), any_value(), any_value()).thenReturn(None) mock_config = mock() mock_config.livestatus_socket = '/path/to/socket' when(livestatus_service.dispatcher).get_current_configuration( ).thenReturn(mock_config) perform_query('FOO;bar', None, 'livestatus') verify(livestatus_service.dispatcher).perform_livestatus_query( 'FOO;bar', '/path/to/socket', None)