Exemplo n.º 1
0
    def test_library_projects_property(self, mocker):
        lib_project = MagicMock(spec=Project, project_type=ProjectType.Library)
        projects = Projects()
        projects.extend([
            lib_project,
            MagicMock(spec=Project, project_type=ProjectType.Standard)
        ])

        library_projects = projects.library_projects

        assert len(library_projects) == 1
        assert lib_project in library_projects
Exemplo n.º 2
0
    def test_standard_projects_property(self, mocker):
        std_project = MagicMock(spec=Project,
                                project_type=ProjectType.Standard)
        projects = Projects()
        projects.extend([
            std_project,
            MagicMock(spec=Project, project_type=ProjectType.Library)
        ])

        result = projects.standard_projects

        assert len(result) == 1
        assert std_project in result
Exemplo n.º 3
0
    def test_build_project_list(self, mocker):
        project1 = MagicMock(spec=Project)
        project2 = MagicMock(spec=Project)
        list1 = [project1, project2]
        project3 = MagicMock(spec=Project)
        list2 = [project3]
        get_projects_mock = mocker.patch.object(ProjectListFactory,
                                                "get_projects_in_folder",
                                                side_effect=[list1, list2, []])
        mocker.patch.object(
            ConfigurationManager,
            "get",
            return_value=MagicMock(
                monorepo_root_folder="root",
                library_folder_name="lib",
                standard_folder_list=["folder1", "folder2"],
            ),
        )

        projects = Projects.projects_factory()

        assert len(projects) == 3
        assert project1 in projects
        assert project2 in projects
        assert project3 in projects
        assert get_projects_mock.call_args_list == [
            call("root/lib"),
            call("root/folder1"),
            call("root/folder2"),
        ]
Exemplo n.º 4
0
    def test_build_version_list_all_new(self, mocker):
        mocker.patch.object(ProjectVersionManager,
                            "load_previous_version_list",
                            return_value=None)

        project1 = MagicMock(spec=Project, project_path="path1")
        project2 = MagicMock(spec=Project, project_path="path2")
        projects = Projects()
        projects.extend([project1, project2])

        project_version_list = ProjectVersionManager().build_version_list(
            projects, "1.0.0")

        assert len(project_version_list) == 2
        assert "path1" in project_version_list
        assert "path2" in project_version_list
        assert project_version_list["path1"] == "1.0.0"
        assert project_version_list["path2"] == "1.0.0"
    def test_standard_projects_filters_as_expected(self, mocker):
        lib = MagicMock(spec=Project, project_type=ProjectType.Library)
        std1 = MagicMock(spec=Project,
                         project_type=ProjectType.Standard,
                         needs_build=True)
        std2 = MagicMock(spec=Project,
                         project_type=ProjectType.Standard,
                         needs_build=False)
        projects = Projects()
        projects.extend([lib, std1, std2])
        req = MagicMock(spec=ProjectBuildRequest)
        project_build_request_mock = mocker.patch(
            "monorepo_builder.build_executor.ProjectBuildRequest",
            return_value=req)

        result = ProjectBuildRequests.standard_projects(projects)

        assert len(result) == 1
        assert req in result
        project_build_request_mock.assert_called_once_with(project=std1)
Exemplo n.º 6
0
    def test_set_project_needs_build_flag(self, mocker):
        lib_proj_1 = MagicMock(spec=Project, needs_build=True)
        lib_proj_1.name = "one"
        lib_proj_2 = MagicMock(spec=Project, needs_build=False)
        lib_proj_2.name = "libtwo"
        std_proj_1 = MagicMock(spec=Project)
        std_proj_1.name = "two"
        std_proj_2 = MagicMock(spec=Project)
        std_proj_2.name = "three"
        projects = MagicMock(
            spec=Projects,
            **{
                "__iter__.return_value": [lib_proj_1, std_proj_1, std_proj_2],
                "library_projects": [lib_proj_1, lib_proj_2],
                "standard_projects": [std_proj_1, std_proj_2],
            },
        )
        previous_1 = MagicMock(spec=Project)
        previous_1.name = "two"
        previous_2 = MagicMock(spec=Project)
        previous_2.name = "one"
        previous_projects = Projects()
        previous_projects.extend([previous_1, previous_2])
        mocker.patch.object(
            ProjectListManager,
            "load_list_from_last_successful_run",
            return_value=previous_projects,
        )

        BuildRunner().identify_projects_needing_build(projects)

        lib_proj_1.set_needs_build_due_to_file_changes.assert_called_once_with(
            previous_2)
        std_proj_1.set_needs_build_due_to_file_changes.assert_called_once_with(
            previous_1)
        std_proj_2.set_needs_build_due_to_file_changes.assert_called_once_with(
            None)
        std_proj_1.set_needs_build_due_to_updated_library_reference.assert_called_once_with(
            ["one"])
        std_proj_2.set_needs_build_due_to_updated_library_reference.assert_called_once_with(
            ["one"])
    def test_library_projects_filters_to_library_projects_needing_build(
            self, mocker):
        lib1 = MagicMock(spec=Project,
                         project_type=ProjectType.Library,
                         needs_build=True)
        lib2 = MagicMock(spec=Project,
                         project_type=ProjectType.Library,
                         needs_build=False)
        std = MagicMock(spec=Project, project_type=ProjectType.Standard)
        projects = Projects()
        projects.extend([lib1, lib2, std])
        req = MagicMock(spec=ProjectBuildRequest)
        project_build_request_mock = mocker.patch(
            "monorepo_builder.build_executor.ProjectBuildRequest",
            return_value=req)

        result = ProjectBuildRequests.library_projects(projects)

        assert len(result) == 1
        assert req in result
        project_build_request_mock.assert_called_once_with(project=lib1)
Exemplo n.º 8
0
 def gather_projects(self) -> Projects:
     write_to_console("Creating Project List", color="blue")
     projects = Projects.projects_factory()
     write_to_console("Identifying projects requiring a build")
     BuildRunner().identify_projects_needing_build(projects)
     return projects