Skip to content

Commit

Permalink
Fix flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
JokeWaumans committed Aug 5, 2024
1 parent 45191cd commit 809179b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
9 changes: 3 additions & 6 deletions mlx/coverity_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

# General
import csv
import json
import logging
import re
from sphinx.util.logging import getLogger

# For Coverity - REST API
import requests

from mlx.coverity_logging import report_info

# Coverity built in Impact statuses
IMPACT_LIST = {"High", "Medium", "Low"}

Expand Down Expand Up @@ -166,13 +163,13 @@ def _request(self, url, data=None):
if data:
response = self.session.post(url, json=data)
else:
response= self.session.get(url)
response = self.session.get(url)
if response.ok:
return response.json()
try:
err_msg= response.json()["message"]
err_msg = response.json()["message"]
except (requests.exceptions.JSONDecodeError, KeyError):
err_msg= response.content.decode()
err_msg = response.content.decode()
logger = getLogger("coverity_logging")
logger.warning(err_msg)
return response.raise_for_status()
Expand Down
16 changes: 8 additions & 8 deletions tests/test_coverity.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def test_get_defects(self):
},
"checkerAttributedata": [
{
"key": "checker_key",
"value": "checker_value"
"key": "checker_key",
"value": "checker_value"
}
]
}
Expand All @@ -85,10 +85,10 @@ def test_get_defects(self):
with requests_mock.mock() as mocker:
with open("tests/column_keys.json", "r") as content:
column_keys = json.loads(content.read())
mocker.get(column_keys_url, json = column_keys)
mocker.get(checkers_url, json = fake_checkers)
mocker.get(stream_url, json = {"stream": "valid"})
mocker.post(issues_url, json = fake_json)
mocker.get(column_keys_url, json=column_keys)
mocker.get(checkers_url, json=fake_checkers)
mocker.get(stream_url, json={"stream": "valid"})
mocker.post(issues_url, json=fake_json)

# Validate stream name
coverity_conf_service.validate_stream(fake_stream)
Expand Down Expand Up @@ -120,11 +120,11 @@ def test_failed_login(self):
stream_url = f"{coverity_conf_service.base_url.rstrip('/')}/streams/{fake_stream}"

with requests_mock.mock() as mocker:
mocker.get(stream_url, headers={"Authorization": "Basic fail"}, status_code = 401)
mocker.get(stream_url, headers={"Authorization": "Basic fail"}, status_code=401)
# Login to Coverity
coverity_conf_service.login("user", "password")
# Validate stream name
with self.assertRaises(requests.HTTPError) as err:
coverity_conf_service.validate_stream(fake_stream)
self.assertEqual(err.exception.response.status_code,401)
self.assertEqual(err.exception.response.status_code, 401)

0 comments on commit 809179b

Please sign in to comment.