-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add schedule queryset request filter integration #35982
Open
BryanttV
wants to merge
5
commits into
openedx:master
Choose a base branch
from
eduNEXT:bav/schedule-queryset-filter-integration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+72
−4
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
beb7fe6
feat: add schedule queryset request filter integration
BryanttV 224fcaf
chore: remove try-except when running filter
BryanttV 82ed56c
chore: upgrade openedx-filters to v1.12.0
BryanttV dbf97ed
test: add filter unit tests
BryanttV 1d46fa7
test: inherit of ModuleStoreTestCase
BryanttV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" | ||
Test cases for the Open edX Filters associated with the schedule app. | ||
""" | ||
|
||
import datetime | ||
from unittest.mock import Mock | ||
|
||
from django.db.models.query import QuerySet | ||
from django.test import override_settings | ||
from openedx_filters import PipelineStep | ||
|
||
from openedx.core.djangoapps.schedules.resolvers import BinnedSchedulesBaseResolver | ||
from openedx.core.djangoapps.schedules.tests.test_resolvers import SchedulesResolverTestMixin | ||
from openedx.core.djangolib.testing.utils import skip_unless_lms | ||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase | ||
|
||
|
||
class TestScheduleQuerySetRequestedPipelineStep(PipelineStep): | ||
"""Pipeline step class to test a configured pipeline step""" | ||
|
||
filtered_schedules = Mock(spec=QuerySet) | ||
|
||
def run_filter(self, schedules): # pylint: disable=arguments-differ | ||
"""Pipeline step to filter the schedules""" | ||
return { | ||
"schedules": self.filtered_schedules, | ||
} | ||
|
||
|
||
@skip_unless_lms | ||
class ScheduleQuerySetRequestedFiltersTest(SchedulesResolverTestMixin, ModuleStoreTestCase): | ||
""" | ||
Tests for the Open edX Filters associated with the schedule queryset requested. | ||
|
||
The following filters are tested: | ||
- ScheduleQuerySetRequested | ||
""" | ||
|
||
def setUp(self): | ||
super().setUp() | ||
self.resolver = BinnedSchedulesBaseResolver( | ||
async_send_task=Mock(name="async_send_task"), | ||
site=self.site, | ||
target_datetime=datetime.datetime.now(), | ||
day_offset=3, | ||
bin_num=1, | ||
) | ||
|
||
@override_settings( | ||
OPEN_EDX_FILTERS_CONFIG={ | ||
"org.openedx.learning.schedule.queryset.requested.v1": { | ||
"pipeline": [ | ||
"openedx.core.djangoapps.schedules.tests.test_filters.TestScheduleQuerySetRequestedPipelineStep", | ||
], | ||
"fail_silently": False, | ||
}, | ||
}, | ||
) | ||
def test_schedule_queryset_requested_filter(self) -> None: | ||
"""Test to verify the schedule queryset was modified by the pipeline step.""" | ||
schedules = self.resolver.get_schedules_with_target_date_by_bin_and_orgs() | ||
|
||
self.assertEqual(TestScheduleQuerySetRequestedPipelineStep.filtered_schedules, schedules) | ||
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
Unchanged files with check annotations Beta
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
} | ||
}, | ||
config: { | ||
text: { | ||
useXhr: () => true | ||
} | ||
} | ||
}); | ||
}).call(this, require, define); |
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
* True if summary configuration is enabled. | ||
*/ | ||
summary_configuration_enabled: null, | ||
/** | ||
* List of tags of the unit. This list is managed by the content_tagging module. | ||
*/ | ||
tags: null, | ||
/** | ||
* True if the xblock is not visible to students only via links. | ||
*/ | ||
hide_from_toc: null, | ||
/** | ||
* True iff this xblock should display a "Contains staff only content" message. | ||
*/ | ||
hide_from_toc_message: null, | ||
}, | ||
initialize: function() { |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also test the default case when the filter is not configured?