Skip to content

Commit

Permalink
fix: add missing course_id term to call
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnuon committed Jan 4, 2024
1 parent 40d9a73 commit 9150b0a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions search/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 6 additions & 7 deletions search/tests/test_api_timing_events.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
# 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()
self.addCleanup(patcher.stop)

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"

Expand All @@ -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,
Expand Down

0 comments on commit 9150b0a

Please sign in to comment.