-
-
Notifications
You must be signed in to change notification settings - Fork 891
Adding teams API #1794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding teams API #1794
Changes from all commits
06a5d52
8e385a7
20fe576
1d25e22
24d6030
7e8c583
1d71f6b
76968c1
0ffae35
bf37718
24efc5c
f7a8235
8569141
cdfd11a
f561715
224505b
4780ce9
7fdf0b8
d740987
d8a08d5
d2b5072
37f34d0
67aa439
09cdd50
09a08f7
b3237f5
df5fbf7
cf3c276
1c3e965
7c57de8
8cbe77e
f879605
0fe0f3c
d4880e4
39a1ced
33ecea3
37b33d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
from contextlib import contextmanager | ||
|
||
from tests.conftest import JiraTestCase, allow_on_cloud | ||
|
||
|
||
@allow_on_cloud | ||
class TeamsTests(JiraTestCase): | ||
def setUp(self): | ||
JiraTestCase.setUp(self) | ||
self.test_team_name = f"testTeamFor_{self.test_manager.project_a}" | ||
self.test_team_type = "OPEN" | ||
self.org_id = os.environ["CI_JIRA_ORG_ID"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how to get the I guess the only real solution is to implement the organisation API and to create a new one before running the tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created a new PR (#1803) based on this one but also adding Organisations API so that I'm able to test the Team API. |
||
self.test_team_description = "test Description" | ||
|
||
@contextmanager | ||
def make_team(self, **kwargs): | ||
try: | ||
new_team = self.jira.create_team( | ||
self.org_id, | ||
self.test_team_description, | ||
self.test_team_name, | ||
self.test_team_type, | ||
) | ||
|
||
if len(kwargs): | ||
raise ValueError("Incorrect kwarg used !") | ||
yield new_team | ||
finally: | ||
new_team.delete() | ||
|
||
def test_team_creation(self): | ||
with self.make_team() as test_team: | ||
self.assertEqual( | ||
self.test_team_name, | ||
test_team["displayName"], | ||
) | ||
self.assertEqual(self.test_team_description, test_team["description"]) | ||
self.assertEqual(self.test_team_type, test_team["teamType"]) | ||
|
||
def test_team_get(self): | ||
with self.make_team() as test_team: | ||
fetched_team = self.jira.get_team(self.org_id, test_team.id) | ||
self.assertEqual( | ||
self.test_team_name, | ||
fetched_team["displayName"], | ||
) | ||
|
||
def test_team_deletion(self): | ||
with self.make_team() as test_team: | ||
ok = self.jira.remove_team(self.org_id, test_team.id) | ||
self.assertTrue(ok) | ||
|
||
def test_updating_team(self): | ||
new_desc = "Fake new description" | ||
new_name = "Fake new Name" | ||
with self.make_team() as test_team: | ||
updated_team = self.jira.update_team( | ||
self.org_id, test_team.id, description=new_desc, displayName=new_name | ||
) | ||
self.assertEqual(new_name, updated_team["displayName"]) | ||
self.assertEqual(new_desc, updated_team["description"]) | ||
|
||
def test_adding_team_members(self): | ||
with self.make_team() as test_team: | ||
self.jira.add_team_members( | ||
self.org_id, test_team.id, members=[self.user_admin["accountId"]] | ||
) | ||
|
||
def test_get_team_members(self): | ||
expected_accounts_id = [self.user_admin["accountId"]] | ||
with self.make_team() as test_team: | ||
self.jira.add_team_members( | ||
self.org_id, test_team.id, members=expected_accounts_id | ||
) | ||
|
||
fetched_account_ids = self.jira.team_members(self.org_id, test_team.id) | ||
self.assertEqual(expected_accounts_id, fetched_account_ids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this pagination implementation should be moved into a helper method, if is is specific to the Teams API I would make it a static method of the Teams Resource
Then you would call it like:
Teams._fetch_pages(session=session, url=url, ...)
I would aim to match as many of the parameters to the function
JIRA._fetch_pages()
if possibleThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory it's not specific to Teams API, but isn't exactly like
JIRA._fetch_pages()
neither as it's using different identifiers for Jira's latest API (why they didn't stick to the same variable names between API idk 🙄 )For now I simply created it as a helper function but if it it's used outside of Teams it's bound to change.