Example #1
0
    def test_task_dependencies(self):
        import pybuilder.reactor

        when(pybuilder.reactor).Task().thenReturn(mock())

        @task
        def task1():
            pass

        @task
        @depends(task1)
        def task2():
            pass

        @task
        def task3():
            pass

        @task
        @depends(optional(task3))
        @dependents("task6")
        def task4():
            pass

        @task
        @dependents("task6", optional(task3))
        def task5():
            pass

        @task
        @depends(task1, optional(task2))
        def task6():
            pass

        module = mock()
        module.task1 = task1
        module.task2 = task2
        module.task3 = task3
        module.task4 = task4
        module.task5 = task5
        module.task6 = task6

        self.reactor.collect_tasks_and_actions_and_initializers(module)

        inorder.verify(pybuilder.reactor).Task("task1", task1, [], '')
        inorder.verify(pybuilder.reactor).Task("task2", task2,
                                               [TaskDependency(task1)], '')
        inorder.verify(pybuilder.reactor).Task("task3", task3,
                                               [TaskDependency(task5, True)],
                                               '')
        inorder.verify(pybuilder.reactor).Task("task4", task4,
                                               [TaskDependency(task3, True)],
                                               '')
        inorder.verify(pybuilder.reactor).Task("task5", task5, [], '')
        inorder.verify(pybuilder.reactor).Task("task6", task6, [
            TaskDependency(task1),
            TaskDependency(task2, True),
            TaskDependency(task4),
            TaskDependency(task5)
        ], '')
Example #2
0
    def test_task_dependencies(self):
        import pybuilder.reactor

        with patch("pybuilder.reactor.Task"):

            @task
            def task1():
                pass

            @task
            @depends(task1)
            def task2():
                pass

            @task
            def task3():
                pass

            @task
            @depends(optional(task3))
            @dependents("task6")
            def task4():
                pass

            @task
            @dependents("task6", optional(task3))
            def task5():
                pass

            @task
            @depends(task1, optional(task2))
            def task6():
                pass

            module = ModuleType("mock_module")
            module.task1 = task1
            module.task2 = task2
            module.task3 = task3
            module.task4 = task4
            module.task5 = task5
            module.task6 = task6

            self.reactor.collect_project_annotations(module)

            pybuilder.reactor.Task.assert_has_calls([
                call("task1", task1, [], ''),
                call("task2", task2, [TaskDependency(task1)], ''),
                call("task3", task3, [TaskDependency(task5, True)], ''),
                call("task4", task4, [TaskDependency(task3, True)], ''),
                call("task5", task5, [], ''),
                call("task6", task6, [
                    TaskDependency(task1),
                    TaskDependency(task2, True),
                    TaskDependency(task4),
                    TaskDependency(task5)
                ], '')
            ])
Example #3
0
    def test_task_dependencies(self):
        import pybuilder.reactor

        when(pybuilder.reactor).Task().thenReturn(mock())

        @task
        def task1():
            pass

        @task
        @depends(task1)
        def task2():
            pass

        @task
        def task3():
            pass

        @task
        @depends(optional(task3))
        @dependents("task6")
        def task4():
            pass

        @task
        @dependents("task6", optional(task3))
        def task5():
            pass

        @task
        @depends(task1, optional(task2))
        def task6():
            pass

        module = mock()
        module.task1 = task1
        module.task2 = task2
        module.task3 = task3
        module.task4 = task4
        module.task5 = task5
        module.task6 = task6

        self.reactor.collect_tasks_and_actions_and_initializers(module)

        inorder.verify(pybuilder.reactor).Task("task1", task1, [], '')
        inorder.verify(pybuilder.reactor).Task("task2", task2, [TaskDependency(task1)], '')
        inorder.verify(pybuilder.reactor).Task("task3", task3, [TaskDependency(task5, True)], '')
        inorder.verify(pybuilder.reactor).Task("task4", task4, [TaskDependency(task3, True)], '')
        inorder.verify(pybuilder.reactor).Task("task5", task5, [], '')
        inorder.verify(pybuilder.reactor).Task("task6", task6, [TaskDependency(task1), TaskDependency(task2, True),
                                                                TaskDependency(task4), TaskDependency(task5)], '')
Example #4
0
    def test_task_dependencies(self):
        import pybuilder.reactor

        with patch("pybuilder.reactor.Task"):
            @task
            def task1():
                pass

            @task
            @depends(task1)
            def task2():
                pass

            @task
            def task3():
                pass

            @task
            @depends(optional(task3))
            @dependents("task6")
            def task4():
                pass

            @task
            @dependents("task6", optional(task3))
            def task5():
                pass

            @task
            @depends(task1, optional(task2))
            def task6():
                pass

            module = ModuleType("mock_module")
            module.task1 = task1
            module.task2 = task2
            module.task3 = task3
            module.task4 = task4
            module.task5 = task5
            module.task6 = task6

            self.reactor.collect_tasks_and_actions_and_initializers(module)

            pybuilder.reactor.Task.assert_has_calls([call("task1", task1, [], ''),
                                                     call("task2", task2, [TaskDependency(task1)], ''),
                                                     call("task3", task3, [TaskDependency(task5, True)], ''),
                                                     call("task4", task4, [TaskDependency(task3, True)], ''),
                                                     call("task5", task5, [], ''),
                                                     call("task6", task6,
                                                          [TaskDependency(task1), TaskDependency(task2, True),
                                                           TaskDependency(task4), TaskDependency(task5)], '')])
Example #5
0
def pdoc_prepare(project, logger):
    """ Asserts that pdoc is executable. """
    logger.debug("Checking if pdoc is executable.")

    assert_can_execute(command_and_arguments=["pdoc", "--version"],
                       prerequisite="pdoc",
                       caller="plugin python.pdoc")

    pdoc_output_dir = project.expand_path("$pdoc_output_dir")
    if not os.path.exists(pdoc_output_dir):
        os.mkdir(pdoc_output_dir)


@task("compile_docs", "Generates HTML documentation tree with pdoc")
@depends("compile_sources", "verify")
@dependents(optional("publish"))
def pdoc_compile_docs(project, logger):
    logger.info("Generating pdoc documentation")

    if not project.get_property("pdoc_module_name"):
        raise BuildFailedException("'pdoc_module_name' must be specified")

    pdoc_command_args = project.get_property("pdoc_command_args", [])
    pdoc_output_dir = project.expand_path("$pdoc_output_dir")

    command_and_arguments = ["pdoc"] + pdoc_command_args
    if "--html" in pdoc_command_args:
        command_and_arguments += ["--html-dir", pdoc_output_dir]
    command_and_arguments += [project.get_property("pdoc_module_name")]

    source_directory = project.expand_path("$pdoc_source")
Example #6
0
@task
@depends(prepare)
@description("Compiles source files that need compilation.")
def compile_sources():
    pass


@task
@depends(compile_sources)
@description("Runs all unit tests.")
def run_unit_tests():
    pass


@task
@depends(compile_sources, optional(run_unit_tests))
@description("Packages the application.")
def package():
    pass


@task
@depends(package)
@description("Runs integration tests on the packaged application.")
def run_integration_tests():
    pass


@task
@depends(run_integration_tests)
@description("Verifies the project and possibly integration tests.")
Example #7
0
@task
@depends(prepare)
@description("Compiles source files that need compilation.")
def compile_sources():
    pass


@task
@depends(compile_sources)
@description("Runs all unit tests.")
def run_unit_tests():
    pass


@task
@depends(compile_sources, optional(run_unit_tests))
@description("Packages the application.")
def package():
    pass


@task
@depends(package)
@description("Runs integration tests on the packaged application.")
def run_integration_tests():
    pass


@task
@depends(run_integration_tests)
@description("Verifies the project and possibly integration tests.")