Skip to content

Commit 94cd132

Browse files
Reorganize/rename hook function variables for clarity
1 parent fd3b6ad commit 94cd132

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

django_expanded_test_cases/test_cases/integration_test_case.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,13 @@ def __init__(self, *args, **kwargs):
101101
# Initialize some check values.
102102
# Initialize these to true. Then the default implementation of each hook function sets to False.
103103
# Presumably if at least one hook is implemented, then it will stay True.
104-
self._implemented_auth_setup_hook = True
105-
self._implemented_pre_assert_hook = True
106-
self._implemented_post_assert_hook = True
104+
105+
class HookClass:
106+
auth_setup_is_okay = True
107+
pre_assert_is_okay = True
108+
post_assert_is_okay = True
109+
110+
self.hook_checks = HookClass()
107111

108112
@classmethod
109113
def setUpClass(cls, *args, debug_print=None, **kwargs):
@@ -2141,7 +2145,7 @@ def _assertResponse__pre_builtin_tests(
21412145

21422146
# Set class variable to track that hook is not implemented.
21432147
# Still using the default implementation that does nothing.
2144-
self._implemented_pre_assert_hook = False
2148+
self.hook_checks.pre_assert_is_okay = False
21452149

21462150
def _assertResponse__post_builtin_tests(
21472151
self,
@@ -2180,7 +2184,7 @@ def _assertResponse__post_builtin_tests(
21802184

21812185
# Set class variable to track that hook is not implemented.
21822186
# Still using the default implementation that does nothing.
2183-
self._implemented_post_assert_hook = False
2187+
self.hook_checks.post_assert_is_okay = False
21842188

21852189
def _get_login_user__extra_user_auth_setup(
21862190
self,
@@ -2205,7 +2209,7 @@ def _get_login_user__extra_user_auth_setup(
22052209

22062210
# Set class variable to track that hook is not implemented.
22072211
# Still using the default implementation that does nothing.
2208-
self._implemented_auth_setup_hook = False
2212+
self.hook_checks.auth_setup_is_okay = False
22092213

22102214
return user
22112215

@@ -2255,8 +2259,8 @@ def _hook_function_warning_check_if_statement(self, user):
22552259
# User is anonymous. Skip auth hook.
22562260
if (
22572261
# Comment to prevent "black" formatting.
2258-
not self._implemented_pre_assert_hook
2259-
and not self._implemented_post_assert_hook
2262+
not self.hook_checks.pre_assert_is_okay
2263+
and not self.hook_checks.post_assert_is_okay
22602264
):
22612265
should_raise_warning = True
22622266

@@ -2265,9 +2269,9 @@ def _hook_function_warning_check_if_statement(self, user):
22652269

22662270
if (
22672271
# Comment to prevent "black" formatting.
2268-
not self._implemented_pre_assert_hook
2269-
and not self._implemented_post_assert_hook
2270-
and not self._implemented_auth_setup_hook
2272+
not self.hook_checks.pre_assert_is_okay
2273+
and not self.hook_checks.post_assert_is_okay
2274+
and not self.hook_checks.auth_setup_is_okay
22712275
):
22722276
should_raise_warning = True
22732277

tests/django_expanded_test_cases/tests/test_integration_case/test_integration_hooks.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ def test_hook_is_called(self):
3131
"""Verifies hook function is called and changes state as expected."""
3232

3333
# Verify initial state of class variable.
34-
self.assertEqual(True, self._implemented_pre_assert_hook)
34+
self.assertEqual(True, self.hook_checks.pre_assert_is_okay)
3535

3636
# Call a basic assertResponse.
3737
# We don't even care if it works, this is only to trigger the hook function.
3838
self.assertResponse('')
3939

4040
# Verify variable changed after call. This variable is only changed in the hook function.
41-
self.assertEqual(False, self._implemented_pre_assert_hook)
41+
self.assertEqual(False, self.hook_checks.pre_assert_is_okay)
4242

4343

4444
class TestIntegrationHooks__CanAccessPostBuiltinHook(IntegrationTestCase):
@@ -51,14 +51,14 @@ def test_hook_is_called(self):
5151
"""Verifies hook function is called and changes state as expected."""
5252

5353
# Verify initial state of class variable.
54-
self.assertEqual(True, self._implemented_post_assert_hook)
54+
self.assertEqual(True, self.hook_checks.post_assert_is_okay)
5555

5656
# Call a basic assertResponse.
5757
# We don't even care if it works, this is only to trigger the hook function.
5858
self.assertResponse('')
5959

6060
# Verify variable changed after call. This variable is only changed in the hook function.
61-
self.assertEqual(False, self._implemented_post_assert_hook)
61+
self.assertEqual(False, self.hook_checks.post_assert_is_okay)
6262

6363

6464
class TestIntegrationHooks__CanAccessAuthSetupHook(IntegrationTestCase):
@@ -74,7 +74,7 @@ def test_hook_is_called(self):
7474
"""
7575

7676
# Verify initial state of class variable.
77-
self.assertEqual(True, self._implemented_auth_setup_hook)
77+
self.assertEqual(True, self.hook_checks.auth_setup_is_okay)
7878

7979
# Call a basic assertResponse.
8080
# We don't even care if it works, this is only to trigger the hook function.
@@ -84,7 +84,7 @@ def test_hook_is_called(self):
8484
)
8585

8686
# Verify variable changed after call. This variable is only changed in the hook function.
87-
self.assertEqual(False, self._implemented_auth_setup_hook)
87+
self.assertEqual(False, self.hook_checks.auth_setup_is_okay)
8888

8989

9090
# endregion Verify Hook Function Access

0 commit comments

Comments
 (0)