Skip to content

Commit

Permalink
Unify test case class names
Browse files Browse the repository at this point in the history
Change class names of unittest test cases so they now follow the same
pattern:

- All end with TestCase
- Abstract ones without their own tests end with BaseTestCase
  • Loading branch information
Glutexo authored and dehort committed Jul 26, 2019
1 parent ebf25c1 commit a2360c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def inject_qs(url, **kwargs):
return urlunsplit((scheme, netloc, path, new_query, fragment))


class BaseAPITestCase(unittest.TestCase):
class APIBaseTestCase(unittest.TestCase):
def _get_valid_auth_header(self):
identity = Identity(account_number=ACCOUNT)
dict_ = {"identity": identity._asdict()}
Expand Down Expand Up @@ -137,7 +137,7 @@ def _response_check(self, response, status, return_response_as_json):
return response


class DBAPITestCase(BaseAPITestCase):
class DBAPITestCase(APIBaseTestCase):
@classmethod
def setUpClass(cls):
"""
Expand Down Expand Up @@ -760,7 +760,7 @@ def test_create_and_update_multiple_hosts_with_different_accounts(self):
i += 1


class PaginationTestCase(BaseAPITestCase):
class PaginationBaseTestCase(APIBaseTestCase):
def _base_paging_test(self, url, expected_number_of_hosts):
def _test_get_page(page, expected_count=1):
test_url = inject_qs(url, page=page, per_page="1")
Expand Down Expand Up @@ -788,7 +788,7 @@ def _test_get_page(page, expected_count=1):
self.get(test_url, 404)


class CreateHostsWithSystemProfileTestCase(DBAPITestCase, PaginationTestCase):
class CreateHostsWithSystemProfileTestCase(DBAPITestCase, PaginationBaseTestCase):
def _valid_system_profile(self):
return {"number_of_cpus": 1,
"number_of_sockets": 2,
Expand Down Expand Up @@ -1088,7 +1088,7 @@ def test_get_system_profile_with_invalid_host_id(self):
self.verify_error_response(response, expected_title="Bad Request", expected_status=400)


class PreCreatedHostsBaseTestCase(DBAPITestCase, PaginationTestCase):
class PreCreatedHostsBaseTestCase(DBAPITestCase, PaginationBaseTestCase):
def setUp(self):
super(PreCreatedHostsBaseTestCase, self).setUp()
self.added_hosts = self.create_hosts()
Expand Down Expand Up @@ -1313,7 +1313,7 @@ def test_query_using_display_name_substring(self):
self._base_paging_test(test_url, len(self.added_hosts))


class QueryByHostIdTestCase(PreCreatedHostsBaseTestCase, PaginationTestCase):
class QueryByHostIdTestCase(PreCreatedHostsBaseTestCase, PaginationBaseTestCase):
def _base_query_test(self, host_id_list, expected_host_list):
url = f"{HOST_URL}/{host_id_list}"
response = self.get(url)
Expand Down Expand Up @@ -1457,7 +1457,7 @@ def test_query_with_maching_insights_id_and_branch_id(self):
self.get(test_url, 200)


class QueryOrderTestCase(PreCreatedHostsBaseTestCase):
class QueryOrderBaseTestCase(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)
Expand All @@ -1477,7 +1477,7 @@ def _get(self, base_url, order_by=None, order_how=None, status=200):
return self.get(full_url, status)


class QueryOrderWithAdditionalHostTestCase(QueryOrderTestCase):
class QueryOrderWithAdditionalHostTestCase(QueryOrderBaseTestCase):
def setUp(self):
super().setUp()
host_wrapper = HostWrapper()
Expand Down Expand Up @@ -1568,7 +1568,7 @@ def tests_hosts_are_ordered_by_display_name_descending(self):
self._assert_host_ids_in_response(response, expected_hosts)


class QueryOrderBadRequestsTestCase(QueryOrderTestCase):
class QueryOrderBadRequestsTestCase(QueryOrderBaseTestCase):
def test_invalid_order_by(self):
for url in self._queries_subtests_with_added_hosts():
with self.subTest(url=url):
Expand Down Expand Up @@ -1811,7 +1811,7 @@ def test_validate_token_on_POST_shared_secret_not_set(self):
self.assertEqual(401, response.status_code)


class HealthTestCase(BaseAPITestCase):
class HealthTestCase(APIBaseTestCase):
"""
Tests the health check endpoint.
"""
Expand Down
2 changes: 1 addition & 1 deletion test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _identity():
return Identity(account_number="some number")


class AuthIdentityFromAuthHeaderTest(AuthIdentityConstructorTestCase):
class AuthIdentityFromAuthHeaderTestCase(AuthIdentityConstructorTestCase):
"""
Tests creating an Identity from a Base64 encoded JSON string, which is what is in
the HTTP header.
Expand Down

0 comments on commit a2360c2

Please sign in to comment.