Skip to content

Commit

Permalink
Merge branch 'pr/rena2damas/1472' into bugfix/mypermissions_args
Browse files Browse the repository at this point in the history
  • Loading branch information
adehad committed Aug 24, 2022
2 parents 3f436d7 + 8e9a9ad commit cffaf5c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions jira/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2634,6 +2634,10 @@ def my_permissions(
) -> Dict[str, Dict[str, Dict[str, str]]]:
"""Get a dict of all available permissions on the server.
``permissions`` is a comma-separated value list of permission keys that is
required in Jira Cloud. For possible and allowable permission values, see
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-permission-schemes/#built-in-permissions
Args:
projectKey (Optional[str]): limit returned permissions to the specified project
projectId (Optional[str]): limit returned permissions to the specified project
Expand Down
2 changes: 1 addition & 1 deletion jira/resilientsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _jira_prepare(self, **original_kwargs) -> dict:
request_headers.update(original_kwargs.get("headers", {}))
prepared_kwargs["headers"] = request_headers

data = original_kwargs.get("data", {})
data = original_kwargs.get("data", None)
if isinstance(data, dict):
# mypy ensures we don't do this,
# but for people subclassing we should preserve old behaviour
Expand Down
19 changes: 19 additions & 0 deletions tests/test_resilientsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,22 @@ def test_passthrough_class():
# WHEN: the dict of request args are prepared
# THEN: The exact same dict is returned
assert passthrough_class.prepare(my_kwargs) is my_kwargs


@patch("requests.Session.request")
def test_unspecified_body_remains_unspecified(mocked_request_method: Mock):
# Disable retries for this test.
session = jira.resilientsession.ResilientSession(max_retries=0)
# Data is not specified here.
session.get(url="mocked_url")
kwargs = mocked_request_method.call_args.kwargs
assert "data" not in kwargs


@patch("requests.Session.request")
def test_nonempty_body_is_forwarded(mocked_request_method: Mock):
# Disable retries for this test.
session = jira.resilientsession.ResilientSession(max_retries=0)
session.get(url="mocked_url", data={"some": "fake-data"})
kwargs = mocked_request_method.call_args.kwargs
assert kwargs["data"] == '{"some": "fake-data"}'
6 changes: 4 additions & 2 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ def test_fields(self):
class MyPermissionsServerTests(JiraTestCase):
def setUp(self):
super().setUp()
if self.jira._is_cloud:
self.skipTest("server only test class")
self.issue_1 = self.test_manager.project_b_issue1

def test_my_permissions(self):
Expand Down Expand Up @@ -214,6 +212,10 @@ def test_my_permissions_by_issue(self):
)
self.assertEqual(len(perms["permissions"]), 3)

def test_missing_required_param_my_permissions_raises_exception(self):
with self.assertRaises(JIRAError):
self.jira.my_permissions()

def test_invalid_param_my_permissions_raises_exception(self):
with self.assertRaises(JIRAError):
self.jira.my_permissions("INVALID_PERMISSION")
Expand Down

0 comments on commit cffaf5c

Please sign in to comment.