예제 #1
0
class InstallBuildDependenciesTest(unittest.TestCase):
    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 tearDown(self):
        unstub()

    def test_should_install_multiple_dependencies(self):
        self.project.build_depends_on("spam")
        self.project.build_depends_on("eggs")
        self.project.build_depends_on_requirements("requirements-dev.txt")

        install_build_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)
        verify(pybuilder.plugins.python.install_dependencies_plugin
               ).execute_command("pip install '-rrequirements-dev.txt'",
                                 any_value(),
                                 shell=True)
    class InstallBuildDependenciesTest(unittest.TestCase):
        def setUp(self):
            self.project = Project("unittest", ".")
            self.project.set_property("dir_install_logs", "any_directory")
            self.logger = mock(Logger)
            initialize_install_dependencies_plugin(self.project)
            when(pybuilder.plugins.python.install_dependencies_plugin
                 ).execute_command(any_value(),
                                   any_value(),
                                   env=any_value(),
                                   shell=False).thenReturn(0)

        def tearDown(self):
            unstub()

        def test_should_install_multiple_dependencies(self):
            self.project.build_depends_on("spam")
            self.project.build_depends_on("eggs")
            self.project.build_depends_on_requirements("requirements-dev.txt")

            install_build_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)
            verify(pybuilder.plugins.python.install_dependencies_plugin
                   ).execute_command(PIP_EXEC_STANZA +
                                     ["install", '-r', 'requirements-dev.txt'],
                                     any_value(),
                                     shell=False)
    class InstallBuildDependenciesTest(unittest.TestCase):
        def setUp(self):
            self.project = Project("unittest", ".")
            self.project.set_property("dir_install_logs", "any_directory")
            self.logger = mock(Logger)
            initialize_install_dependencies_plugin(self.project)
            when(pybuilder.plugins.python.install_dependencies_plugin).execute_command(any_value(),
                                                                                       any_value(),
                                                                                       env=any_value(),
                                                                                       shell=False).thenReturn(0)

        def tearDown(self):
            unstub()

        def test_should_install_multiple_dependencies(self):
            self.project.build_depends_on("spam")
            self.project.build_depends_on("eggs")
            self.project.build_depends_on_requirements("requirements-dev.txt")

            install_build_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)
            verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
                PIP_EXEC_STANZA + ["install", '-r', 'requirements-dev.txt'], any_value(), shell=False)
class InstallBuildDependenciesTest(unittest.TestCase):
    def setUp(self):
        self.project = Project("unittest", ".")
        self.project.set_property("dir_install_logs", "any_directory")
        self.project.set_property("dir_target", "/any_target_directory")
        self.logger = Mock(Logger)
        initialize_install_dependencies_plugin(self.project)

    @patch("pybuilder.pip_utils.create_constraint_file")
    @patch("pybuilder.pip_utils.get_package_version", return_value={})
    @patch("pybuilder.pip_utils.execute_command", return_value=0)
    def test_should_install_multiple_dependencies(self, exec_command,
                                                  get_package_version,
                                                  constraint_file):
        self.project.build_depends_on("spam")
        self.project.build_depends_on("eggs")
        self.project.build_depends_on_requirements("requirements-dev.txt")

        install_build_dependencies(self.logger, self.project)

        exec_command(PIP_EXEC_STANZA + ["install", "spam"], ANY, shell=False)
        exec_command(PIP_EXEC_STANZA + ["install", "eggs"], ANY, shell=False)
        exec_command(PIP_EXEC_STANZA +
                     ["install", '-r', 'requirements-dev.txt'],
                     ANY,
                     shell=False)
class InstallBuildDependenciesTest(unittest.TestCase):
    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 tearDown(self):
        unstub()

    def test_should_install_multiple_dependencies(self):
        self.project.build_depends_on("spam")
        self.project.build_depends_on("eggs")
        self.project.build_depends_on_requirements("requirements-dev.txt")

        install_build_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
        )
        verify(pybuilder.plugins.python.install_dependencies_plugin).execute_command(
            "pip install '-rrequirements-dev.txt'", any_value(), shell=True
        )
    class InstallBuildDependenciesTest(unittest.TestCase):
        def setUp(self):
            self.project = Project("unittest", ".")
            self.project.set_property("dir_install_logs", "any_directory")
            self.logger = Mock(Logger)
            initialize_install_dependencies_plugin(self.project)

        @patch("pybuilder.plugins.python.install_dependencies_plugin.execute_command", return_value=0)
        def test_should_install_multiple_dependencies(self, exec_command, get_package_version):
            self.project.build_depends_on("spam")
            self.project.build_depends_on("eggs")
            self.project.build_depends_on_requirements("requirements-dev.txt")

            install_build_dependencies(self.logger, self.project)

            exec_command(PIP_EXEC_STANZA + ["install", "spam"], ANY, shell=False)
            exec_command(PIP_EXEC_STANZA + ["install", "eggs"], ANY, shell=False)
            exec_command(PIP_EXEC_STANZA + ["install", '-r', 'requirements-dev.txt'], ANY, shell=False)
예제 #7
0
class InstallBuildDependenciesTest(unittest.TestCase):
    def setUp(self):
        self.project = Project("unittest", ".")
        self.project.set_property("install_env", "whatever")
        self.project.set_property("dir_install_logs", "any_directory")
        self.project.set_property("dir_target", "/any_target_directory")
        self.logger = Mock(Logger)

        self.reactor = Mock()
        self.pyb_env = Mock()
        self.pyb_env.executable = ["a/b"]
        self.pyb_env.env_dir = "a"
        self.pyb_env.execute_command.return_value = 0
        self.reactor.python_env_registry = {"whatever": self.pyb_env}

        initialize_install_dependencies_plugin(self.project)

    @patch("pybuilder.install_utils.tail_log")
    @patch("pybuilder.install_utils.open")
    @patch("pybuilder.install_utils.create_constraint_file")
    @patch("pybuilder.install_utils.get_packages_info", return_value={})
    def test_should_install_multiple_dependencies(self, *_):
        self.project.build_depends_on("spam")
        self.project.build_depends_on("eggs")
        self.project.build_depends_on_requirements("requirements-dev.txt")

        install_build_dependencies(self.logger, self.project, self.reactor)

        exec_cmd = self.pyb_env.execute_command
        call_stanza = self.pyb_env.executable + PIP_MODULE_STANZA + [
            "install", "-c", ANY
        ]

        exec_cmd.assert_called_with(
            call_stanza + ["eggs", "spam", "-r", "requirements-dev.txt"],
            outfile_name=ANY,
            error_file_name=ANY,
            env=ANY,
            cwd=None,
            shell=False,
            no_path_search=True)
def dependencies(project: Project):
    project.depends_on_requirements('requirements.txt')
    project.build_depends_on_requirements('requirements-dev.txt')