diff --git a/jira/client.py b/jira/client.py index c51119245..88b4dc452 100644 --- a/jira/client.py +++ b/jira/client.py @@ -2401,30 +2401,39 @@ def priority(self, id: str) -> Priority: # Projects - def projects(self) -> List[Project]: + def projects(self, expand: Optional[str] = None) -> List[Project]: """Get a list of project Resources from the server visible to the current authenticated user. + Args: + expand (Optional[str]): extra information to fetch for each project + such as projectKeys and description. + Returns: List[Project] """ - r_json = self._get_json("project") + params = {} + if expand is not None: + params["expand"] = expand + r_json = self._get_json("project", params=params) projects = [ Project(self._options, self._session, raw_project_json) for raw_project_json in r_json ] return projects - def project(self, id: str) -> Project: + def project(self, id: str, expand: Optional[str] = None) -> Project: """Get a project Resource from the server. Args: id (str): ID or key of the project to get + expand (Optional[str]): extra information to fetch for the project + such as projectKeys and description. Returns: Project """ - return self._find_for_resource(Project, id) + return self._find_for_resource(Project, id, expand=expand) # non-resource @translate_resource_args diff --git a/tests/tests.py b/tests/tests.py index ee77e31b8..c2adc76ad 100755 --- a/tests/tests.py +++ b/tests/tests.py @@ -1548,10 +1548,20 @@ def test_projects(self): projects = self.jira.projects() self.assertGreaterEqual(len(projects), 2) + def test_projects_expand(self): + project = self.jira.projects(expand="description")[0] + self.assertTrue(hasattr(project, "description")) + self.assertFalse(hasattr(project, "lead")) + def test_project(self): project = self.jira.project(self.project_b) self.assertEqual(project.key, self.project_b) + def test_project_expand(self): + project = self.jira.project(self.project_b, expand="description") + self.assertTrue(hasattr(project, "description")) + self.assertFalse(hasattr(project, "lead")) + # I have no idea what avatars['custom'] is and I get different results every time # def test_project_avatars(self): # avatars = self.jira.project_avatars(self.project_b)