Skip to content

Commit

Permalink
Merge branch 'REST-API' of github.com:melexis/sphinx-coverity-extensi…
Browse files Browse the repository at this point in the history
…on into REST-API
  • Loading branch information
JokeWaumans committed Aug 13, 2024
2 parents 72d6be1 + 559b6b9 commit 00ff922
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
13 changes: 7 additions & 6 deletions mlx/coverity_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class CoverityDefectService:
_version = "v2"

def __init__(self, hostname):
self._base_url = f"https://{hostname.strip('/')}"
self._api_endpoint = f"https://{hostname.strip('/')}/api/{self.version}"
hostname = hostname.strip('/')
self._base_url = f"https://{hostname}"
self._api_endpoint = f"https://{hostname}/api/{self.version}"
self._checkers = []
self._columns = {}
self.logger = getLogger("coverity_logging")
Expand Down Expand Up @@ -99,7 +100,7 @@ def validate_stream(self, stream):
Args:
stream (str): The stream name
"""
url = f"{self.api_endpoint.rstrip('/')}/streams/{stream}"
url = f"{self.api_endpoint}/streams/{stream}"
self._request(url)

def retrieve_issues(self, filters):
Expand All @@ -118,7 +119,7 @@ def retrieve_issues(self, filters):
"rowCount": -1,
"sortOrder": "asc",
}
url = f"{self.api_endpoint.rstrip('/')}/issues/search?{urlencode(params)}"
url = f"{self.api_endpoint}/issues/search?{urlencode(params)}"
return self._request(url, filters)

def retrieve_column_keys(self):
Expand All @@ -132,7 +133,7 @@ def retrieve_column_keys(self):
"queryType": "bySnapshot",
"retrieveGroupByColumns": "false"
}
url = f"{self.api_endpoint.rstrip('/')}/issues/columns?{urlencode(params)}"
url = f"{self.api_endpoint}/issues/columns?{urlencode(params)}"
columns = self._request(url)
if columns:
self._columns = {column["name"].lower(): column["columnKey"] for column in columns}
Expand All @@ -145,7 +146,7 @@ def retrieve_checkers(self):
list[str]: The list of valid checkers
"""
if not self.checkers:
url = f"{self.api_endpoint.rstrip('/')}/checkerAttributes/checker"
url = f"{self.api_endpoint}/checkerAttributes/checker"
checkers = self._request(url)
if checkers and "checkerAttributedata" in checkers:
self._checkers = [checker["key"] for checker in checkers["checkerAttributedata"]]
Expand Down
8 changes: 4 additions & 4 deletions tests/test_coverity.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def test_get_defects(self):

# urls that are used in GET or POST requests
column_keys_url = (
coverity_conf_service.api_endpoint.rstrip("/")
coverity_conf_service.api_endpoint
+ "/issues/columns?queryType=bySnapshot&retrieveGroupByColumns=false"
)
checkers_url = f"{coverity_conf_service.api_endpoint.rstrip('/')}/checkerAttributes/checker"
stream_url = f"{coverity_conf_service.api_endpoint.rstrip('/')}/streams/{fake_stream}"
checkers_url = f"{coverity_conf_service.api_endpoint}/checkerAttributes/checker"
stream_url = f"{coverity_conf_service.api_endpoint}/streams/{fake_stream}"
issues_url = (
coverity_conf_service.api_endpoint.rstrip("/")
coverity_conf_service.api_endpoint
+ "/issues/search?includeColumnLabels=true&offset=0&queryType=bySnapshot&rowCount=-1&sortOrder=asc"
)

Expand Down

0 comments on commit 00ff922

Please sign in to comment.