Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
skiedude committed Nov 22, 2024
1 parent 7179097 commit 275c3db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
28 changes: 15 additions & 13 deletions jira/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,21 @@ def _get_url(self, path: str) -> str:

def _validate_self_self_url(self) -> None:
"""In the case of a proxy, use the configured option server URL."""
self_parsed = urlparse(self.self)
server_parsed = urlparse(self._options["server"])
if self_parsed.netloc != server_parsed.netloc:
self.self = urlunparse(
ParseResult(
scheme=server_parsed.scheme,
netloc=server_parsed.netloc,
path=self_parsed.path,
params=self_parsed.params,
query=self_parsed.query,
fragment=self_parsed.fragment,
if getattr(self, "self", None):
self.self: str
self_parsed = urlparse(self.self)
server_parsed = urlparse(self._options["server"])
if self_parsed.netloc != server_parsed.netloc:
self.self = urlunparse(
ParseResult(
scheme=server_parsed.scheme,
netloc=server_parsed.netloc,
path=self_parsed.path,
params=self_parsed.params,
query=self_parsed.query,
fragment=self_parsed.fragment,
)
)
)

def update(
self,
Expand Down Expand Up @@ -1523,7 +1525,7 @@ def __init__(
session: ResilientSession,
raw: dict[str, Any] | None = None,
):
self.self = None
self.self = ""

Resource.__init__(self, path, options, session, self.AGILE_BASE_URL)
if raw:
Expand Down
4 changes: 4 additions & 0 deletions tests/resources/test_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ def test_update_label_with_proxy(self):

labelarray = ["testLabel"]
fields = {"labels": labelarray}
#This simulates when your Jira server is behind a proxy
#The self address returned will be different from the configured server
issue.self = f"https://foo.bar/jira/rest/api/2/issue/{issue.id}"
issue.update(fields=fields)
self.assertEqual(issue.fields.labels, ["testLabel"])
Expand Down Expand Up @@ -395,6 +397,8 @@ def test_delete_with_proxy(self):
issuetype=self.test_manager.CI_JIRA_ISSUE,
)
key = issue.key
#This simulates when your Jira server is behind a proxy
#The self address returned will be different from the configured server
issue.self = f"https://foo.bar/jira/rest/api/2/issue/{issue.id}"
issue.delete()
self.assertRaises(JIRAError, self.jira.issue, key)
Expand Down

0 comments on commit 275c3db

Please sign in to comment.