-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Update email constants for single release candidate #20170
base: develop
Are you sure you want to change the base?
Update email constants for single release candidate #20170
Conversation
* CAN_SEND_EMAILS is now a platform parameter. This will be switched on for the prod server and off for the other servers. * CAN_SEND_EDITOR_ROLE_EMAILS, CAN_SEND_FEEDBACK_MESSAGE_EMAILS and CAN_SEND_SUBSCRIPTION_EMAILS are replaced with CAN_SEND_TRANSACTIONAL_EMAILS. * DEFAULT_EMAIL_UPDATES_PREFERENCE is set to True in feconf.py and is not configurable per-server. * REQUIRE_EMAIL_ON_MODERATOR_ACTION is set to True and the constant is removed.
Hi @kevintab95, can you complete the following:
|
Hi @vojtechjelinek, @DubeySandeep, @kevintab95, PTAL at this PR, it adds a new cron job. |
Hi @kevintab95 please assign the required reviewer(s) for this PR. Thanks! |
@oppia/release-coordinators please note that for the release containing these changes, the RC must ensure that the CAN_SEND_EMAILS platform parameter is set in production and unset on other servers. Thanks. |
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! Took a pass.
self.swap_to_always_return( | ||
platform_parameter_services, | ||
'get_platform_parameter_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.
self.swap_to_always_return( | |
platform_parameter_services, | |
'get_platform_parameter_value', | |
True | |
) | |
) | |
self.swap_to_always_return( | |
platform_parameter_services, | |
'get_platform_parameter_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.
ditto below
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.
Done
core/domain/feedback_services.py
Outdated
if (can_send_emails and ( | ||
feconf.CAN_SEND_TRANSACTIONAL_EMAILS and |
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 somehow cleanup this if
at this point it is almost unreadable. At least something like this:
# TODO(#12079): Figure out a better way to avoid sending feedback
# thread emails for contributor dashboard suggestions.
message_changed = len(text) > 0 or old_statuses[index] != new_statuses[index]
if (
can_send_emails and
feconf.CAN_SEND_TRANSACTIONAL_EMAILS and
author_id is not None and
user_services.is_user_registered(author_id)) and
message_changed and
should_send_email
):
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.
Done.
Unassigning @vojtechjelinek since the review is done. |
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.
@vojtechjelinek PTAL
core/domain/feedback_services.py
Outdated
) | ||
if ( | ||
server_can_send_emails and | ||
( |
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.
Done.
core/tests/test_utils.py
Outdated
) -> Callable[[Callable[ | ||
..., _GenericHandlerFunctionReturnType]], | ||
Callable[..., _GenericHandlerFunctionReturnType] | ||
]: |
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.
Done.
core/tests/test_utils.py
Outdated
with swap_get_platform_parameter_value_function( | ||
platform_parameter_name_value_tuples): | ||
return func(*args, **kwargs) |
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.
Done.
…stants-for-single-rc
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 @kevintab95! Couple small things, but looks pretty good for codeowners :)
Also @kevintab95 I think this needs a testing doc? It's trivial (set the param on) but we need a way to make sure this gets into the release instructions.
core/controllers/classifier_test.py
Outdated
@@ -186,6 +187,9 @@ def test_trained_classifier_handler(self) -> None: | |||
classifier_training_job.status, | |||
feconf.TRAINING_JOB_STATUS_COMPLETE) | |||
|
|||
@test_utils.use_platform_parameters( |
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 "set" is better than "use", since we are always using all platform params (just that, sometimes, they have their default values).
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.
Done.
PlatformDataTypes. The value of the platform parameter if the | ||
parameter is present in the platform_parameter_names list. | ||
""" | ||
platform_parameter_name_value_dict = dict( |
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.
What if a parameter that's retrieved is not specified in the given list of tuples?
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've added a check for this now. Done.
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 have no concerns for the changes (for Android), and am otherwise deferring to @seanlip for Android & core owners approvals since he's already looking at the PR.
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.
PTAL @seanlip. Thanks!
core/controllers/classifier_test.py
Outdated
@@ -186,6 +187,9 @@ def test_trained_classifier_handler(self) -> None: | |||
classifier_training_job.status, | |||
feconf.TRAINING_JOB_STATUS_COMPLETE) | |||
|
|||
@test_utils.use_platform_parameters( |
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.
Done.
PlatformDataTypes. The value of the platform parameter if the | ||
parameter is present in the platform_parameter_names list. | ||
""" | ||
platform_parameter_name_value_dict = dict( |
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've added a check for this now. Done.
I've submitted a testing request for 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.
Thank you @kevintab95, I have no concerns re frontend changes.
Unassigning @Nik-09 since they have already approved the PR. |
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 Kevin, a couple of follow-up comments!
core/tests/test_utils.py
Outdated
@@ -453,10 +453,18 @@ def mock_get_platform_parameter_value( | |||
Returns: | |||
PlatformDataTypes. The value of the platform parameter if the | |||
parameter is present in the platform_parameter_names list. | |||
|
|||
Raises: | |||
Exception. If the parameter_name is not present in the |
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.
If the --> The
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.
Done.
core/tests/test_utils.py
Outdated
""" | ||
platform_parameter_name_value_dict = dict( | ||
(x.value, y) for x, y in platform_parameter_name_value_tuples | ||
) | ||
if parameter_name not in platform_parameter_name_value_dict: | ||
raise Exception( | ||
'Unknown platform parameter name: %s' % parameter_name |
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 make this more explicit -- something like "The value for the platform parameter XYZ was needed in this test, but not specified in the XXX decorator. Please add a XXX decorator with this information."
Also just to confirm -- if a backend test uses a platform parameter (directly or indirectly), then they must specify its value, is that correct?
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.
Done.
Regarding the second question, this is true if the test uses the decorator i.e. if a test uses the decorator, it will need to exhaustively define all the platform parameter that it requires or it will throw the error above. There may still be tests that rely on calling the actual procedure (not mocking) and/or there may be other tests that mocks the method a different way (e.g. always return xxx).
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 @kevintab95, sg. One question though -- have we modified all the tests that rely on calling the actual procedure / mock the method a different way to use the new decorator instead? I think that's important because, otherwise, devs will simply copy those old tests if it's the first example they see.
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.
The way I went about these changes were to find out places where the email related platform parameter is used and then modify those tests to use the decorator instead. I do see around 24 places in the test files where platform_parameter_services.get_platform_parameter_value
is mocked without the decorator e.g.
oppia/core/controllers/improvements_test.py
Lines 720 to 726 in 60b6d8e
def test_custom_high_bounce_rate_obsoletion_threshold(self) -> None: | |
swap_get_platform_parameter_value = self.swap_to_always_return( | |
platform_parameter_services, | |
'get_platform_parameter_value', | |
0.05 | |
) | |
Can this be fixed in a separate PR as it seems out of scope for the current one?
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.
Update: Per offline discussion, I will be handling these cases in the same PR.
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.
PTAL @seanlip, thanks!
core/tests/test_utils.py
Outdated
@@ -453,10 +453,18 @@ def mock_get_platform_parameter_value( | |||
Returns: | |||
PlatformDataTypes. The value of the platform parameter if the | |||
parameter is present in the platform_parameter_names list. | |||
|
|||
Raises: | |||
Exception. If the parameter_name is not present in the |
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.
Done.
core/tests/test_utils.py
Outdated
""" | ||
platform_parameter_name_value_dict = dict( | ||
(x.value, y) for x, y in platform_parameter_name_value_tuples | ||
) | ||
if parameter_name not in platform_parameter_name_value_dict: | ||
raise Exception( | ||
'Unknown platform parameter name: %s' % parameter_name |
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.
Done.
Regarding the second question, this is true if the test uses the decorator i.e. if a test uses the decorator, it will need to exhaustively define all the platform parameter that it requires or it will throw the error above. There may still be tests that rely on calling the actual procedure (not mocking) and/or there may be other tests that mocks the method a different way (e.g. always return xxx).
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.
LGTM!
Unassigning @vojtechjelinek since they have already approved the PR. |
Overview
Essential Checklist
Please follow the instructions for making a code change.
Testing doc (for PRs with Beam jobs that modify production server data)
Proof that changes are correct
Proof of changes on desktop with slow/throttled network
Proof of changes on mobile phone
Proof of changes in Arabic language
PR Pointers