-
Notifications
You must be signed in to change notification settings - Fork 4.2k
refactor: migrated FEATURES dict settings to top-level in core files and fixed related test files. #37389
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
refactor: migrated FEATURES dict settings to top-level in core files and fixed related test files. #37389
Conversation
feanil
left a comment
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.
Thanks for the PR @Akanshu-2u, it looks like the right changes but maybe not enough fixes in the tests which may be trying to override the features dict still. Once the tests get fixed up, I think this would be fine to land. Let me know when you've got the tests passing. Until then, I'm gonna mark this as a draft PR.
1f8e60f to
e3f8473
Compare
| } | ||
|
|
||
| utils.update_course_details(mock_request, self.course.id, payload, None) | ||
| utils.update_course_details(mock_request, self.course.id, payload, self.course) |
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.
why are we changing the args ? This is un-related to features.
Was it because of tests failing ?
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.
Yes, the CI test was failing with this error AttributeError: 'NoneType' object has no attribute 'entrance_exam_enabled' . So changed the arg to fix this.
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.
I believe this is happening because the setting value for ENTRANCE_EXAMS is now being set to true instead of false which is not the correct expected behavior. So I think the fix needs to be to patch the toggle rather than the item in the features dictionary not to change the test code here.
jcapphelix
left a comment
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.
While core file changes are all good.
I have some questions on test cases, mainly :-
- Why are some feature flags not removed ?
- Is it something that is supposed to be removed later ?
|
jcapphelix
left a comment
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.
My Queries are all answered.
Good to go from my side.
kdmccormick
left a comment
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.
Thanks @Akanshu-2u , these changes all look good.
But, I am confused why you chose to update these references in particular. There are many remaining references to FEATURES that we will need to clean up in a future PR.
Were these particular references causing bugs?
I focused on fixing only the test files that referenced the |
Why did you choose to refactor those settings within this PR? |
I guess this may help you with the explanation: #37396 (comment) |
|
Okay, so you have chosen some remaining references, but not all of them, correct? That is fine, but the description of this PR says that it "moved remaining features dicts settings" and "Removed FEATURES dictionary". These are not true, and it is misleading to have them in the PR description when there are still so many FEATURES references remaining in the platform. Could you please edit your PR and commit message? |
Addressed. Modified the PR title and description which shall be more convenient for the changes achieved in this PR. |
6cfcc78 to
a3cad1f
Compare
|
I rebased and resolved conflicts but it looks like some change maybe broke some rate limiting. @Akanshu-2u can you look into that when you have some time? |
|
I apologize @feanil, but @Akanshu-2u is on to other things. He created this PR to begin with out of a misunderstanding of what was required of him for handling the DEPR on the 2U-side. Hopefully this PR helps get the work started by someone, but I need him working on some other things right now. Note: I thought the PR was ready to merge. I didn't realize it would involve additional work. |
|
In that case, closing this for now as I don't think we have anyone to work on it and it will probably get stale and full of conflicts pretty regularly given the number of things it touches. |
Hii @feanil , I’ve rebased the latest master onto my branch and the CI is now passing successfully. Please feel free to review, approve, and merge the PR. Thanks! |
feanil
left a comment
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.
Mostly looks good, just had a couple of questions.
| } | ||
|
|
||
| utils.update_course_details(mock_request, self.course.id, payload, None) | ||
| utils.update_course_details(mock_request, self.course.id, payload, self.course) |
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.
I believe this is happening because the setting value for ENTRANCE_EXAMS is now being set to true instead of false which is not the correct expected behavior. So I think the fix needs to be to patch the toggle rather than the item in the features dictionary not to change the test code here.
| ) | ||
| @override_waffle_flag(toggles.LEGACY_STUDIO_SCHEDULE_DETAILS, True) | ||
| def test_visibility_of_entrance_exam_section(self, feature_flags): | ||
| @patch.object(milestones_helpers.ENABLE_MILESTONES_APP, 'is_enabled', return_value=False) |
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.
Why patch the toggle rather than just using override_setting which is more standard and what you're using in some of the later files?
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.
Implemented the suggestion.
|
|
||
| @mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_CONTENT_LIBRARIES': False}) | ||
| def test_with_libraries_disabled(self): | ||
| @patch.object(toggles.ENABLE_CONTENT_LIBRARIES, 'is_enabled', return_value=False) |
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.
I think it's much clearer if you just override the django settings rather than the toggle.
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.
Yes, following the suggestion I added override setting instead of patch toggle.
|
|
||
| def setUp(self): | ||
| self.mfe_config_api_url = reverse("mfe_config_api:config") | ||
| cache.clear() |
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.
Why was this needed?
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.
This change was needed because CI checks were repeatedly failing due to cached data being retained for the test file. Clearing the cache ensures the tests run cleanly and pass as expected.
feanil
left a comment
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.
Looks like one more file needs to be updated and then this is good to land I think.
|
|
||
| @patch.dict(settings.FEATURES, {'ENABLE_EXPORT_GIT': True}) | ||
| def test_fetch_giturl_present(self): | ||
| @patch.object(toggles.EXPORT_GIT, 'is_enabled', return_value=True) |
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.
Is there a reason this isn't using override_settings as well?
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.
Changed this to override settings and ensured other files do not require changes for override settings.
feanil
left a comment
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.
Changes look great, thanks @Akanshu-2u
Description:
Refactored
FEATURESsettings to top-level in core files and updated related tests for consistency and maintainability.Solution:
SettingDictToggleclass toSettingToggle.FEATURESsetting to top level in core file.FEATUREreferences intact.Note: The unrelated
FEATUREreferences are working fine due to the use offeatureproxy, hence for the time being left those unchanged.Private JIRA Link:
BOMS-200
Reference PR:
#37067
Note:
FEATURESdict.