Example #1
0
    def test_read_requirements_file_not_found(self, mocker):
        join_mock = mocker.patch("monorepo_builder.projects.os.path.join",
                                 side_effect=["file1", "file2"])
        path_mock = mocker.patch.object(Path, "__init__", return_value=None)
        project = Project(project_path="here")
        exist_mock = mocker.patch.object(Path,
                                         "exists",
                                         side_effect=[False, False])
        mocker.patch.object(Project, "name", return_value="project")

        with pytest.raises(RequirementsFileNotFoundException):
            project.read_requirements_file()

        assert join_mock.call_args_list == [
            call("here", "requirements.txt"),
            call("here", "package.json"),
        ]
        assert path_mock.call_args_list == [call("file1"), call("file2")]
        assert exist_mock.call_count == 2
Example #2
0
    def test_read_requirements_file_for_python(self, mocker):
        join_mock = mocker.patch("monorepo_builder.projects.os.path.join",
                                 side_effect=["file1", "file2"])
        path_mock = mocker.patch.object(Path, "__init__", return_value=None)
        project = Project(project_path="here")
        exist_mock = mocker.patch.object(Path, "exists", return_value=True)
        mocker.patch.object(Path, "read_text", return_value="content")

        result = project.read_requirements_file()

        assert join_mock.call_args_list == [
            call("here", "requirements.txt"),
            call("here", "package.json"),
        ]
        path_mock.assert_called_once_with("file1")
        exist_mock.assert_called_once()
        assert result == "content"