Skip to content

Commit

Permalink
Fix F841 rule
Browse files Browse the repository at this point in the history
Fixed the F841 Flake8 rule complaning about unused variables.
  • Loading branch information
Glutexo committed Jul 11, 2019
1 parent c91e5e0 commit ce1e730
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
4 changes: 2 additions & 2 deletions api/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def add_host_list(host_list):
"detail": str(e.messages),
"type": "unknown",
"host": host})
except Exception as e:
except Exception:
number_of_errors += 1
logger.exception("Error adding host", extra={"host": host})
response_host_list.append({"status": 500,
Expand Down Expand Up @@ -279,7 +279,7 @@ def find_hosts_by_hostname_or_id(account_number, hostname):
host_id = hostname
filter_list.append(Host.id == host_id)
logger.debug("Adding id (uuid) to the filter list")
except Exception as e:
except Exception:
# Do not filter using the id
logger.debug("The hostname (%s) could not be converted into a UUID",
hostname,
Expand Down
4 changes: 2 additions & 2 deletions app/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def authentication_header_handler(apikey, required_scopes=None):
try:
identity = from_auth_header(apikey)
validate(identity)
except Exception as e:
except Exception:
login_failure_count.inc()
logger.debug("Failed to validate identity header value",
exc_info=True)
Expand All @@ -29,7 +29,7 @@ def bearer_token_handler(token):
try:
identity = from_bearer_token(token)
validate(identity)
except Exception as e:
except Exception:
login_failure_count.inc()
logger.debug("Failed to validate bearer token value",
exc_info=True)
Expand Down
18 changes: 5 additions & 13 deletions test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,31 +1235,25 @@ def test_update_fields(self):
self.assertEqual(host[key], patch_doc[key])

def test_patch_with_branch_id_parameter(self):
original_id = self.added_hosts[0].id
self.added_hosts[0].id

patch_doc = {"display_name": "branch_id_test"}

url_host_id_list = self._build_host_id_list_for_url(self.added_hosts)

test_url = f"{HOST_URL}/{url_host_id_list}?branch_id=123"

response_data = self.patch(test_url,
patch_doc,
200)
self.patch(test_url, patch_doc, 200)

def test_update_fields_on_multiple_hosts(self):
original_id = self.added_hosts[0].id

patch_doc = {"display_name": "fred_flintstone",
"ansible_host": "barney_rubble"}

url_host_id_list = self._build_host_id_list_for_url(self.added_hosts)

test_url = f"{HOST_URL}/{url_host_id_list}"

response_data = self.patch(test_url,
patch_doc,
200)
self.patch(test_url, patch_doc, 200)

response_data = self.get(test_url, 200)

Expand Down Expand Up @@ -1403,8 +1397,6 @@ def test_query_using_fqdn_one_result(self):
assert any(result["display_name"] == host.display_name for host in expected_host_list)

def test_query_using_non_existant_fqdn(self):
host_list = self.added_hosts

response = self.get(HOST_URL + "?fqdn=ROFLSAUCE.com")

self.assertEqual(len(response["results"]), 0)
Expand Down Expand Up @@ -1575,7 +1567,7 @@ def test_query_with_maching_insights_id_and_branch_id(self):

test_url = HOST_URL + "?insights_id=" + valid_insights_id + "&branch_id=123"

response = self.get(test_url, 200)
self.get(test_url, 200)


class QueryOrderTestCase(PreCreatedHostsBaseTestCase):
Expand Down Expand Up @@ -1712,7 +1704,7 @@ def test_invalid_order_how(self):
def test_only_order_how(self):
for url in self._queries_subtests_with_added_hosts():
with self.subTest(url=url):
response = self._get(url, None, "ASC", 400)
self._get(url, None, "ASC", 400)



Expand Down

0 comments on commit ce1e730

Please sign in to comment.