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
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
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)
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)