diff --git a/app/exceptions.py b/app/exceptions.py index 268aa3cb3..c4083a7d3 100644 --- a/app/exceptions.py +++ b/app/exceptions.py @@ -1,5 +1,3 @@ - - class InventoryException(Exception): def __init__(self, status=400, title=None, detail=None, type="about:blank"): self.status = status @@ -13,6 +11,5 @@ def to_json(self): class InputFormatException(InventoryException): - def __init__(self, detail): InventoryException.__init__(self, title="Bad Request", detail=detail) diff --git a/app/logging.py b/app/logging.py index 84f8f6035..2b6cc7066 100644 --- a/app/logging.py +++ b/app/logging.py @@ -86,6 +86,7 @@ class ContextualFilter(logging.Filter): to explicitly retrieve/pass around the request id for each log message. """ + def filter(self, log_record): try: log_record.request_id = threadctx.request_id diff --git a/tasks/__init__.py b/tasks/__init__.py index 7dd274530..37ae77536 100644 --- a/tasks/__init__.py +++ b/tasks/__init__.py @@ -12,7 +12,6 @@ class NullProducer: - def send(self, topic, value=None): logger.debug("NullProducer - logging message: topic (%s) - message: %s" % (topic, value)) diff --git a/test_api.py b/test_api.py index 802e07f9f..a2159d5be 100755 --- a/test_api.py +++ b/test_api.py @@ -148,7 +148,6 @@ def _response_check(self, response, status, return_response_as_json): class DBAPITestCase(BaseAPITestCase): - @classmethod def setUpClass(cls): """ @@ -717,7 +716,6 @@ def test_create_host_with_invalid_ansible_host(self): class ResolveDisplayNameOnCreationTestCase(DBAPITestCase): - def test_create_host_without_display_name_and_without_fqdn(self): """ This test should verify that the display_name is set to the id @@ -776,7 +774,6 @@ def test_create_host_without_display_name_and_with_fqdn(self): class BulkCreateHostsTestCase(DBAPITestCase): - def _get_valid_auth_header(self): return build_valid_auth_header() @@ -862,7 +859,6 @@ def _test_get_page(page, expected_count=1): class CreateHostsWithSystemProfileTestCase(DBAPITestCase, PaginationTestCase): - def _valid_system_profile(self): return {"number_of_cpus": 1, "number_of_sockets": 2, @@ -1212,7 +1208,6 @@ def create_hosts(self): class PatchHostTestCase(PreCreatedHostsBaseTestCase): - def test_update_fields(self): original_id = self.added_hosts[0].id @@ -1307,7 +1302,6 @@ def test_invalid_host_id(self): class DeleteHostsTestCase(PreCreatedHostsBaseTestCase): - def test_create_then_delete(self): original_id = self.added_hosts[0].id @@ -1317,7 +1311,6 @@ def test_create_then_delete(self): self.get(url, 200) class MockEmitEvent: - def __init__(self): self.events = [] @@ -1420,7 +1413,6 @@ def test_query_using_display_name_substring(self): class QueryByHostIdTestCase(PreCreatedHostsBaseTestCase, PaginationTestCase): - def _base_query_test(self, host_id_list, expected_host_list): url = f"{HOST_URL}/{host_id_list}" response = self.get(url) @@ -1505,7 +1497,6 @@ def test_query_invalid_paging_parameters(self): class QueryByHostnameOrIdTestCase(PreCreatedHostsBaseTestCase): - def _base_query_test(self, query_value, expected_number_of_hosts): test_url = HOST_URL + "?hostname_or_id=" + query_value @@ -1538,7 +1529,6 @@ def test_query_using_non_existent_id(self): class QueryByInsightsIdTestCase(PreCreatedHostsBaseTestCase): - def _test_url(self, query_value): return HOST_URL + "?insights_id=" + query_value @@ -1573,7 +1563,6 @@ def test_query_with_maching_insights_id_and_branch_id(self): class QueryOrderTestCase(PreCreatedHostsBaseTestCase): - def _queries_subtests_with_added_hosts(self): host_id_list = [host.id for host in self.added_hosts] url_host_id_list = ",".join(host_id_list) @@ -1598,7 +1587,6 @@ def _get(self, base_url, order_by=None, order_how=None, status=200): class QueryOrderWithAdditionalHostTestCase(QueryOrderTestCase): - def setUp(self): super().setUp() host_wrapper = HostWrapper() @@ -1621,7 +1609,6 @@ def _added_hosts_by_display_name_asc(self): # Hosts with same display_name are ordered by updated descending self.added_hosts[3], self.added_hosts[0], - self.added_hosts[1], self.added_hosts[2] ) @@ -1630,7 +1617,6 @@ def _added_hosts_by_display_name_desc(self): return ( self.added_hosts[2], self.added_hosts[1], - # Hosts with same display_name are ordered by updated descending self.added_hosts[3], self.added_hosts[0] @@ -1692,7 +1678,6 @@ def tests_hosts_are_ordered_by_display_name_descending(self): class QueryOrderBadRequestsTestCase(QueryOrderTestCase): - def test_invalid_order_by(self): for url in self._queries_subtests_with_added_hosts(): with self.subTest(url=url): diff --git a/test_unit.py b/test_unit.py index d2c567c8f..d208b5bb0 100755 --- a/test_unit.py +++ b/test_unit.py @@ -20,6 +20,7 @@ class ApiOperationTestCase(TestCase): Test the API operation decorator that increments the request counter with every call. """ + @patch("api.api_request_count.inc") def test_counter_is_incremented(self, inc): @api_operation @@ -183,7 +184,6 @@ def test_account_number_is_not_set_for_trusted_system(self): class ConfigTestCase(TestCase): - def test_configuration_with_env_vars(self): app_name = "brontocrane" path_prefix = "r/slaterock/platform" @@ -237,7 +237,6 @@ def test_config_development_settings(self): class HostOrderHowTestCase(TestCase): - def test_asc(self): column = Mock() result = _order_how(column, "ASC") @@ -259,7 +258,6 @@ def test_error(self): @patch("api.host._order_how") @patch("api.host.Host.modified_on") class HostParamsToOrderByTestCase(TestCase): - def test_default_is_updated_desc(self, modified_on, order_how): actual = _params_to_order_by(None, None) expected = (modified_on.desc.return_value,) @@ -307,7 +305,6 @@ def test_order_by_display_name_desc(self, display_name, modified_on, order_how): class HostParamsToOrderByErrorsTestCase(TestCase): - def test_order_by_bad_field_raises_error(self): with self.assertRaises(ValueError): _params_to_order_by(Mock(), "fqdn")