Skip to content

Commit

Permalink
test: add tests for course enrollment sink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Jun 17, 2024
1 parent 5c8f0f1 commit 452c966
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion platform_plugin_aspects/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def receive_course_enrollment_changed( # pylint: disable=unused-argument # pra
sender, **kwargs
):
"""
Receives ENROLL_STATUS_CHANGE
Receives ENROLL_STATUS_CHANGE signal and queues the dump job.
"""
from platform_plugin_aspects.tasks import ( # pylint: disable=import-outside-toplevel
dump_data_to_clickhouse,
Expand Down
2 changes: 1 addition & 1 deletion platform_plugin_aspects/sinks/base_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def send_item(self, serialized_item, many=False):
writer.writerow(node.values())
else:
writer.writerow(serialized_item.values())
print("ClickHouse CSV output", output.getvalue().encode("utf-8"))

request = requests.Request(
"POST",
self.ch_url,
Expand Down
20 changes: 20 additions & 0 deletions platform_plugin_aspects/sinks/tests/test_course_enrollment_sink.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
Test the course enrollment sink module.
"""

from unittest.mock import patch

from platform_plugin_aspects.sinks import CourseEnrollmentSink


@patch("platform_plugin_aspects.sinks.ModelBaseSink.get_queryset")
def test_get_queryset(mock_get_queryset):
"""
Test the get_queryset method.
"""
sink = CourseEnrollmentSink(None, None)

sink.get_queryset()

mock_get_queryset.assert_called_once_with(None)
mock_get_queryset.return_value.select_related.assert_called_once_with("user")
4 changes: 1 addition & 3 deletions platform_plugin_aspects/sinks/tests/test_external_id_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ def test_get_queryset(mock_get_queryset):
sink.get_queryset()

mock_get_queryset.assert_called_once_with(None)
mock_get_queryset.return_value.select_related.assert_called_once_with(
"user", "external_id_type"
)
mock_get_queryset.return_value.select_related.assert_called_once_with("user")

0 comments on commit 452c966

Please sign in to comment.