From e94df6a26affe20e4df814a1f1949c0021884505 Mon Sep 17 00:00:00 2001 From: Bryann Valderrama Date: Wed, 10 Apr 2024 17:04:10 -0500 Subject: [PATCH] test: add unit test --- .../learning/tests/test_filters.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/openedx_filters/learning/tests/test_filters.py b/openedx_filters/learning/tests/test_filters.py index c8e8f91..f872d5d 100644 --- a/openedx_filters/learning/tests/test_filters.py +++ b/openedx_filters/learning/tests/test_filters.py @@ -21,6 +21,7 @@ CourseUnenrollmentStarted, DashboardRenderStarted, InstructorDashboardRenderStarted, + ORASubmissionViewRenderStarted, StudentLoginRequested, StudentRegistrationRequested, VerticalBlockChildRenderStarted, @@ -546,6 +547,36 @@ def test_halt_instructor_dashboard_render(self, dashboard_exception, attributes) self.assertDictContainsSubset(attributes, exception.__dict__) + def test_ora_submission_view_render_started(self): + """ + Test ORASubmissionViewRenderStarted filter behavior under normal conditions. + + Expected behavior: + - The filter must have the signature specified. + - The filter should return context and template_name in that order. + """ + result = ORASubmissionViewRenderStarted.run_filter(self.context, self.template_name) + + self.assertTupleEqual((self.context, self.template_name,), result) + + @data( + ( + ORASubmissionViewRenderStarted.RenderInvalidTemplate, + {"context": {"course": Mock()}, "template_name": "custom-template.html"}, + ), + ) + @unpack + def test_halt_ora_submission_view_render(self, dashboard_exception, attributes): + """ + Test for the ora submission view exceptions attributes. + + Expected behavior: + - The exception must have the attributes specified. + """ + exception = dashboard_exception(message="You can't access the view", **attributes) + + self.assertDictContainsSubset(attributes, exception.__dict__) + class TestCohortFilters(TestCase): """