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_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_EXEC_STANZA + ["install", '-r', "requirements.txt"], 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_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, exec_command, get_package_version, constraint_file): dependency = Dependency("spam", url="some_url") install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", "--force-reinstall", 'some_url'], ANY, env=ANY, 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 install 'spam'", any_value(), shell=True)
def test_should_install_dependency_with_version(self, exec_command, get_package_version, constraint_file): dependency = Dependency("spam", "0.1.2") install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", 'spam>=0.1.2'], ANY, env=ANY, shell=False)
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_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 install '-rrequirements.txt'", any_value(), shell=True)
def test_should_install_dependency_with_url_even_if_version_is_given(self, exec_command, get_package_version): dependency = Dependency("spam", version="0.1.2", url="some_url") install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", "--force-reinstall", 'some_url'], ANY, env=ANY, shell=False)
def test_should_install_dependency_without_version_on_windows_derivate(self, exec_command, get_package_version): dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", "spam"], ANY, env=ANY, 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_with_version_and_operator(self, exec_command, get_package_version): dependency = Dependency("spam", "==0.1.2") install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", 'spam==0.1.2'], ANY, env=ANY, shell=False)
def test_should_install_requirements_file_dependency(self, exec_command, get_package_version, constraint_file): dependency = RequirementsFile("requirements.txt") install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", '-r', "requirements.txt"], ANY, env=ANY, 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 install 'spam'", any_value(), shell=True)
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 install '-rrequirements.txt'", any_value(), shell=True)
def test_should_install_dependency_without_version_on_windows_derivate(self, platform): platform.return_value = "win32" dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command( "pip install spam", any_value(), shell=True)
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 install --upgrade 'spam'", any_value(), shell=True)
def test_should_not_use_insecure_flags_when_pip_version_is_too_low(self, exec_command, _, get_package_version): dependency = Dependency("spam") self.project.set_property("install_dependencies_insecure_installation", ["spam"]) install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", 'spam'], ANY, env=ANY, shell=False)
def test_should_install_dependency_without_version_on_windows_derivate(self, platform): platform.return_value = "win32" dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command( "pip install spam", any_value(), shell=True)
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 install 'some_url'", any_value(), shell=True)
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 install --upgrade 'spam'", any_value(), shell=True)
def test_should_install_dependency_without_version_on_windows_derivate(self, exec_command, get_package_version, constraint_file): dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", "spam"], ANY, env=ANY, 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_EXEC_STANZA + ["install", 'spam'], any_value(), env=any_value(), shell=False)
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 install 'some_url'", any_value(), shell=True)
def test_should_upgrade_dependencies(self, exec_command, get_package_version, constraint_file): self.project.set_property("install_dependencies_upgrade", True) dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", "--upgrade", 'spam'], ANY, env=ANY, 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_EXEC_STANZA + ["install", "--upgrade", 'spam'], any_value(), env=any_value(), shell=False)
def test_should_install_dependency_insecurely_when_property_is_set(self): dependency = Dependency("spam") self.project.set_property("install_dependencies_insecure_installation", ["spam"]) when(pybuilder.plugins.python.install_dependencies_plugin)._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 install --allow-unverified spam --allow-external spam 'spam'", any_value(), shell=True)
def test_should_install_dependency_using_custom_index_url(self, exec_command, get_package_version): self.project.set_property("install_dependencies_index_url", "some_index_url") dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", "--index-url", "some_index_url", 'spam'], ANY, env=ANY, shell=False)
def test_should_use_extra_index_url_when_index_url_is_not_set(self, exec_command, get_package_version): self.project.set_property("install_dependencies_extra_index_url", "some_extra_index_url") dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", "--extra-index-url", "some_extra_index_url", 'spam'], ANY, env=ANY, shell=False)
def test_should_install_dependency_insecurely_when_property_is_set(self, exec_command, _, get_package_version): dependency = Dependency("spam") self.project.set_property("install_dependencies_insecure_installation", ["spam"]) install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", "--allow-unverified", "spam", "--allow-external", "spam", 'spam'], ANY, env=ANY, shell=False)
def test_should_not_use_insecure_flags_when_pip_version_is_too_low(self, exec_command, _, get_package_version, constraint_file): dependency = Dependency("spam") self.project.set_property("install_dependencies_insecure_installation", ["spam"]) install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", 'spam'], ANY, env=ANY, 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 install 'spam'", any_value(), shell=True)
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_install_dependency_using_custom_index_url(self): self.project.set_property( "install_dependencies_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 install --index-url some_index_url 'spam'", any_value(), shell=True)
def test_should_install_dependency_using_custom_index_url(self): self.project.set_property("install_dependencies_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", "--index-url", "some_index_url", 'spam'], any_value(), env=any_value(), shell=False)
def test_should_install_dependency_using_custom_index_url(self): self.project.set_property( "install_dependencies_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 install --index-url some_index_url 'spam'", any_value(), shell=True)
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.plugins.python.install_dependencies_plugin)._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 install 'spam'", any_value(), shell=True)
def test_should_install_dependency_insecurely_when_property_is_set(self): dependency = Dependency("spam") self.project.set_property("install_dependencies_insecure_installation", ["spam"]) when(pybuilder.plugins.python.install_dependencies_plugin)._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 install --allow-unverified spam --allow-external spam 'spam'", any_value(), shell=True)
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_with_version_and_operator( self, exec_command, get_package_version): dependency = Dependency("spam", "==0.1.2") install_dependency(self.logger, self.project, dependency) exec_command(PIP_EXEC_STANZA + ["install", 'spam==0.1.2'], ANY, env=ANY, shell=False)
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_insecurely_when_property_is_set(self, exec_command, _, get_package_version, constraint_file): dependency = Dependency("spam") self.project.set_property("install_dependencies_insecure_installation", ["spam"]) install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", "--allow-unverified", "spam", "--allow-external", "spam", 'spam'], ANY, env=ANY, shell=False)
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_use_extra_index_url_when_index_url_is_not_set(self, exec_command, get_package_version, constraint_file): self.project.set_property("install_dependencies_extra_index_url", "some_extra_index_url") dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) exec_command( PIP_EXEC_STANZA + ["install", "--extra-index-url", "some_extra_index_url", 'spam'], ANY, env=ANY, shell=False)
def test_should_install_dependency_with_url_even_if_version_is_given( self, exec_command, get_package_version): dependency = Dependency("spam", version="0.1.2", url="some_url") install_dependency(self.logger, self.project, dependency) exec_command(PIP_EXEC_STANZA + ["install", "--force-reinstall", 'some_url'], ANY, env=ANY, shell=False)
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(self, exec_command, get_package_version): dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) exec_command.assert_called_with(PIP_EXEC_STANZA + ["install", '--upgrade', 'spam'], ANY, env=ANY, 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_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_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_index_and_extra_index_url_when_index_and_extra_index_url_are_set(self): self.project.set_property( "install_dependencies_index_url", "some_index_url") self.project.set_property( "install_dependencies_extra_index_url", "some_extra_index_url") dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command( "pip install --index-url some_index_url --extra-index-url some_extra_index_url 'spam'", any_value( ), shell=True)
def test_should_install_dependency_using_custom_index_url( self, exec_command, get_package_version): self.project.set_property("install_dependencies_index_url", "some_index_url") dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) exec_command(PIP_EXEC_STANZA + ["install", "--index-url", "some_index_url", 'spam'], ANY, env=ANY, shell=False)
def test_should_install_dependency_without_version(self, exec_command, get_package_version, constraint_file): dependency = Dependency("spam") install_dependency(self.logger, self.project, dependency) exec_command.assert_called_with(PIP_EXEC_STANZA + ["install"] + (["--upgrade"] if pip_utils.pip_version < "9.0" else ["--upgrade", "--upgrade-strategy", "only-if-needed"]) + ['-c', 'unittest/any_target_directory/install_dependencies_constraints', 'spam'], ANY, env=ANY, shell=False)
def test_should_install_dependency_using_custom_index_url(self): self.project.set_property("install_dependencies_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", "--index-url", "some_index_url", 'spam'], any_value(), env=any_value(), shell=False)