Skip to content

Commit b564d38

Browse files
refactor: change base exception name to OpenEdxFilterException
1 parent c2ac7dc commit b564d38

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

openedx_filters/exceptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55

6-
class HookFilterException(Exception):
6+
class OpenEdxFilterException(Exception):
77
"""
88
Base exception for filters.
99
@@ -20,7 +20,7 @@ class HookFilterException(Exception):
2020

2121
def __init__(self, message="", redirect_to=None, status_code=None, **kwargs):
2222
"""
23-
Init method for HookFilterException.
23+
Init method for OpenEdxFilterException.
2424
2525
It's designed to allow flexible instantiation through **kwargs.
2626
"""
@@ -33,6 +33,6 @@ def __init__(self, message="", redirect_to=None, status_code=None, **kwargs):
3333

3434
def __str__(self):
3535
"""
36-
Show string representation of HookFilterException using its message.
36+
Show string representation of OpenEdxFilterException using its message.
3737
"""
38-
return "HookFilterException: {}".format(self.message)
38+
return "OpenEdxFilterException: {}".format(self.message)

openedx_filters/pipeline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
from logging import getLogger
55

6-
from .exceptions import HookFilterException
6+
from .exceptions import OpenEdxFilterException
77
from .utils import get_functions_for_pipeline, get_pipeline_configuration
88

99
log = getLogger(__name__)
@@ -41,7 +41,7 @@ def run_pipeline(hook_name, *args, **kwargs):
4141
an object different than Dict or None.
4242
4343
Exceptions raised:
44-
HookFilterException: custom exception re-raised when a function raises
44+
OpenEdxFilterException: custom exception re-raised when a function raises
4545
an exception of this type and raise_exception is set to True. This
4646
behavior is common when using filters.
4747
@@ -67,7 +67,7 @@ def run_pipeline(hook_name, *args, **kwargs):
6767
)
6868
return result
6969
out.update(result)
70-
except HookFilterException as exc:
70+
except OpenEdxFilterException as exc:
7171
if raise_exception:
7272
log.exception(
7373
"Exception raised while running '%s':\n %s", function.__name__, exc,

openedx_filters/tests/test_exceptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
"""
44
from django.test import TestCase
55

6-
from ..exceptions import HookFilterException
6+
from ..exceptions import OpenEdxFilterException
77

88

99
class TestCustomHookFilterException(TestCase):
1010
"""
11-
Test class used to check flexibility when using HookFilterException.
11+
Test class used to check flexibility when using OpenEdxFilterException.
1212
"""
1313

1414
def test_exception_extra_arguments(self):
1515
"""
16-
This method raises HookFilterException with custom dynamic arguments.
16+
This method raises OpenEdxFilterException with custom dynamic arguments.
1717
1818
Expected behavior:
1919
Custom parameters can be accessed as instance arguments.
2020
"""
21-
hook_exception = HookFilterException(custom_arg="custom_argument")
21+
hook_exception = OpenEdxFilterException(custom_arg="custom_argument")
2222

2323
self.assertEqual(
2424
hook_exception.custom_arg, "custom_argument", # pylint: disable=no-member

openedx_filters/tests/test_pipeline.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from django.test import TestCase
77

8-
from ..exceptions import HookFilterException
8+
from ..exceptions import OpenEdxFilterException
99
from ..pipeline import run_pipeline
1010

1111

@@ -54,7 +54,7 @@ def test_run_empty_pipeline(self, get_functions_mock, get_configuration_mock):
5454
def test_raise_hook_exception(self, get_functions_mock, get_configuration_mock):
5555
"""
5656
This method runs a pipeline with a function that raises
57-
HookFilterException. This means that fail_silently must be set to
57+
OpenEdxFilterException. This means that fail_silently must be set to
5858
False.
5959
6060
Expected behavior:
@@ -65,14 +65,14 @@ def test_raise_hook_exception(self, get_functions_mock, get_configuration_mock):
6565
"fail_silently": False,
6666
}
6767
exception_message = "There was an error executing filter X."
68-
function = Mock(side_effect=HookFilterException(message=exception_message))
68+
function = Mock(side_effect=OpenEdxFilterException(message=exception_message))
6969
function.__name__ = "function_name"
7070
get_functions_mock.return_value = [function]
71-
log_message = "Exception raised while running '{func_name}':\n HookFilterException: {exc_msg}".format(
71+
log_message = "Exception raised while running '{func_name}':\n OpenEdxFilterException: {exc_msg}".format(
7272
func_name="function_name", exc_msg=exception_message,
7373
)
7474

75-
with self.assertRaises(HookFilterException), self.assertLogs() as captured:
75+
with self.assertRaises(OpenEdxFilterException), self.assertLogs() as captured:
7676
run_pipeline(self.hook_name, **self.kwargs)
7777
self.assertEqual(
7878
captured.records[0].getMessage(), log_message,
@@ -83,7 +83,7 @@ def test_raise_hook_exception(self, get_functions_mock, get_configuration_mock):
8383
def test_not_raise_hook_exception(self, get_functions_mock, get_hook_config_mock):
8484
"""
8585
This method runs a pipeline with a function that raises
86-
HookFilterException but raise_exception is set to False. This means
86+
OpenEdxFilterException but raise_exception is set to False. This means
8787
fail_silently must be set to True or not defined.
8888
8989
Expected behavior:
@@ -96,7 +96,7 @@ def test_not_raise_hook_exception(self, get_functions_mock, get_hook_config_mock
9696
return_value = {
9797
"request": Mock(),
9898
}
99-
function_with_exception = Mock(side_effect=HookFilterException)
99+
function_with_exception = Mock(side_effect=OpenEdxFilterException)
100100
function_without_exception = Mock(return_value=return_value)
101101
get_functions_mock.return_value = [
102102
function_with_exception,

openedx_filters/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def get_filter_config(hook_name):
123123
the pipeline are defined.
124124
- fail_silently (bool): determines whether the pipeline can
125125
raise exceptions while executing. If its value is True then
126-
exceptions (HookFilterException) are caught and the execution
126+
exceptions (OpenEdxFilterException) are caught and the execution
127127
continues, if False then exceptions are re-raised and the
128128
execution fails.
129129

0 commit comments

Comments
 (0)