-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from openedx/cag/enrollment-sink
feat: add course enrollment sink
- Loading branch information
Showing
10 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""User profile sink""" | ||
|
||
from platform_plugin_aspects.sinks.base_sink import ModelBaseSink | ||
from platform_plugin_aspects.sinks.serializers import CourseEnrollmentSerializer | ||
|
||
|
||
class CourseEnrollmentSink(ModelBaseSink): # pylint: disable=abstract-method | ||
""" | ||
Sink for user CourseEnrollment model | ||
""" | ||
|
||
model = "course_enrollment" | ||
unique_key = "id" | ||
clickhouse_table_name = "course_enrollment" | ||
timestamp_field = "time_last_dumped" | ||
name = "Course Enrollment" | ||
serializer_class = CourseEnrollmentSerializer | ||
|
||
def get_queryset(self, start_pk=None): | ||
return super().get_queryset(start_pk).select_related("user") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
platform_plugin_aspects/sinks/tests/test_course_enrollment_sink.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |