From f35eed4e4c5c813fb2b3312575853d69b45e8515 Mon Sep 17 00:00:00 2001 From: Usman Khalid <2200617@gmail.com> Date: Wed, 3 Mar 2021 16:38:36 +0500 Subject: [PATCH] test: Fix test_capa_module.py::ProblemBlockTest::test_demand_hint_logging. --- .../xmodule/xmodule/tests/test_capa_module.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/common/lib/xmodule/xmodule/tests/test_capa_module.py b/common/lib/xmodule/xmodule/tests/test_capa_module.py index f79d197e45..30ee3e0782 100644 --- a/common/lib/xmodule/xmodule/tests/test_capa_module.py +++ b/common/lib/xmodule/xmodule/tests/test_capa_module.py @@ -1642,26 +1642,16 @@ class ProblemBlockTest(unittest.TestCase): # lint-amnesty, pylint: disable=miss assert not result['should_enable_next_hint'] def test_demand_hint_logging(self): - def mock_location_text(self): # lint-amnesty, pylint: disable=unused-argument - """ - Mock implementation of __unicode__ or __str__ for the module's location. - """ - return u'i4x://edX/capa_test/problem/meh' - + """ + Test calling get_demand_hunt() results in an event being published. + """ module = CapaFactory.create(xml=self.demand_xml) - # Re-mock the module_id to a fixed string, so we can check the logging - module.location = Mock(module.location) - if six.PY2: - module.location.__unicode__ = mock_location_text - else: - module.location.__str__ = mock_location_text - with patch.object(module.runtime, 'publish') as mock_track_function: module.get_problem_html() module.get_demand_hint(0) mock_track_function.assert_called_with( module, 'edx.problem.hint.demandhint_displayed', - {'hint_index': 0, 'module_id': u'i4x://edX/capa_test/problem/meh', + {'hint_index': 0, 'module_id': str(module.location), 'hint_text': 'Demand 1', 'hint_len': 2} )