From 9150b0ad6082ba9ae39474e44ca91457fad5766f Mon Sep 17 00:00:00 2001 From: David Nuon Date: Thu, 4 Jan 2024 12:27:33 -0800 Subject: [PATCH] fix: add missing course_id term to call --- search/api.py | 2 ++ search/tests/test_api_timing_events.py | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/search/api.py b/search/api.py index f8592516..fde7010d 100644 --- a/search/api.py +++ b/search/api.py @@ -96,6 +96,7 @@ def perform_search( emit_api_timing_event(search_term, course_id, filter_generation_timer, processing_timer, search_timer) return results + def emit_api_timing_event(search_term, course_id, filter_generation_timer, processing_timer, search_timer): """ Emit the timing events for the search API @@ -120,6 +121,7 @@ def emit_api_timing_event(search_term, course_id, filter_generation_timer, proce }, }) + def course_discovery_search(search_term=None, size=20, from_=0, field_dictionary=None): """ Course Discovery activities against the search engine index of course details diff --git a/search/tests/test_api_timing_events.py b/search/tests/test_api_timing_events.py index 342f853a..1c11347e 100644 --- a/search/tests/test_api_timing_events.py +++ b/search/tests/test_api_timing_events.py @@ -1,21 +1,21 @@ -# pylint: disable=too-few-public-methods -# pylint: disable=too-many-ancestors """ Tests for timing functionality """ import datetime +from unittest.mock import patch, call from django.test import TestCase from django.test.utils import override_settings from search.tests.mock_search_engine import MockSearchEngine from search.utils import Timer from search.api import emit_api_timing_event -from unittest.mock import patch, call + @override_settings(SEARCH_ENGINE="search.tests.mock_search_engine.MockSearchEngine") class TimingEventsTest(TestCase): """ Tests to see if timing events are emitted""" def setUp(self): + super().setUp() MockSearchEngine.destroy() patcher = patch('search.api.track') self.mock_track = patcher.start() @@ -23,11 +23,9 @@ def setUp(self): def tearDown(self): MockSearchEngine.destroy() - return super().tearDown() - - def test_perform_search(self): - # pylint: disable=protected-access + super().tearDown() + def test_perform_search(self): search_term = "testing search" course_id = "mock.course.id" @@ -47,6 +45,7 @@ def test_perform_search(self): timing_event_call = self.mock_track.emit.mock_calls[0] expected_call = call("edx.course.search.executed", { "search_term": search_term, + "course_id": course_id, "filter_generation_time": { "start": filter_generation_timer.start_time, "end": filter_generation_timer.end_time,