-
Notifications
You must be signed in to change notification settings - Fork 384
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
Add new notification when OT approvals are obtained #4685
Open
DanielRyanSmith
wants to merge
3
commits into
main
Choose a base branch
from
4520_new-approvals-notification
base: main
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.
Open
Changes from all commits
Commits
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
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 |
---|---|---|
|
@@ -142,3 +142,69 @@ def test_notify_subscribers_of_new_comments(self, mock_task_helpers): | |
self.feature_1, self.gate_1, '[email protected]', 'fake comments') | ||
|
||
mock_task_helpers.assert_called_once() | ||
|
||
|
||
class NotifierHelpersTest(testing_config.CustomTestCase): | ||
def setUp(self): | ||
self.feature_1 = FeatureEntry( | ||
name='feature a', summary='sum', category=1, | ||
owner_emails=['[email protected]', | ||
'[email protected]']) | ||
self.feature_1.put() | ||
|
||
feature_id = self.feature_1.key.integer_id() | ||
self.ot_stage = Stage( | ||
id=123, | ||
feature_id=feature_id, | ||
stage_type=150) | ||
self.extension_stage = Stage( | ||
id=456, | ||
feature_id=feature_id, | ||
stage_type=151) | ||
self.ot_stage.put() | ||
self.extension_stage.put() | ||
|
||
self.gate_1 = Gate(id=123, feature_id=feature_id, stage_id=123, | ||
gate_type=2, state=Vote.APPROVED) | ||
self.gate_1.put() | ||
|
||
self.gate_2 = Gate(id=123, feature_id=feature_id, stage_id=123, | ||
gate_type=2, state=Vote.NA) | ||
self.gate_2.put() | ||
|
||
self.gate_3 = Gate(id=123, feature_id=feature_id, stage_id=456, | ||
gate_type=3, state=Vote.APPROVED) | ||
self.gate_3.put() | ||
|
||
def tearDown(self): | ||
for kind in [FeatureEntry, Stage, Gate]: | ||
for entity in kind.query(): | ||
entity.key.delete() | ||
|
||
@mock.patch( | ||
'internals.notifier_helpers.send_trial_creation_approved_notification') | ||
def test_notify_approvals__creation(self, mock_sender): | ||
"""OT creation approval notification is sent when all gates are approved.""" | ||
notifier_helpers.notify_approvals( | ||
self.feature_1, self.ot_stage,self.gate_1) | ||
mock_sender.assert_called_once() | ||
|
||
@mock.patch( | ||
'internals.notifier_helpers.send_trial_creation_approved_notification') | ||
def test_notify_approvals__creation_gates_unapproved(self, mock_sender): | ||
"""OT creation approval notification is only sent if all gates are | ||
approved.""" | ||
# A separate gate related to the OT stage is not approved. | ||
self.gate_2.state = Vote.DENIED | ||
self.gate_2.put() | ||
notifier_helpers.notify_approvals( | ||
self.feature_1, self.ot_stage, self.gate_1) | ||
mock_sender.assert_not_called() | ||
|
||
@mock.patch( | ||
'internals.notifier_helpers.send_trial_extension_approved_notification') | ||
def test_notify_approvals__extension(self, mock_sender): | ||
"""OT extension approved notification sent when gate is approved.""" | ||
notifier_helpers.notify_approvals( | ||
self.feature_1, self.extension_stage, self.gate_3) | ||
mock_sender.assert_called_once() |
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 |
---|---|---|
|
@@ -1213,6 +1213,31 @@ def test_make_activated_email(self): | |
TESTDATA['test_make_activated_email.html']) | ||
|
||
|
||
class OTCreationApprovedHandlerTest(testing_config.CustomTestCase): | ||
def setUp(self): | ||
self.contacts = ['[email protected]', | ||
'[email protected]', | ||
'[email protected]'] | ||
self.feature_1 = FeatureEntry( | ||
id=1, name='feature one', summary='sum', category=1, feature_type=0) | ||
self.feature_1.put() | ||
|
||
def tearDown(self): | ||
self.feature_1.key.delete() | ||
|
||
def test_make_creation_processed_email(self): | ||
with test_app.app_context(): | ||
handler = notifier.OTCreationApprovedHandler() | ||
fe_dict = converters.feature_entry_to_json_verbose(self.feature_1) | ||
email_task = handler.build_email(fe_dict, self.contacts) | ||
# TESTDATA.make_golden(email_task['html'], 'test_make_creation_approved_email.html') | ||
self.assertEqual( | ||
email_task['subject'], | ||
'You can now submit your origin trial creation request') | ||
self.assertEqual(email_task['html'], | ||
TESTDATA['test_make_creation_approved_email.html']) | ||
|
||
|
||
class OTCreationProcessedHandlerTest(testing_config.CustomTestCase): | ||
def setUp(self): | ||
self.contacts = ['[email protected]', | ||
|
28 changes: 28 additions & 0 deletions
28
internals/testdata/notifier_test/test_make_creation_approved_email.html
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,28 @@ | ||
|
||
<div style="background: #eee; padding: 0 16px 16px"> | ||
<div style="color: #666; padding: 8px 0 0 16px;"></div> | ||
|
||
<div style="padding: 8px; background: white; border-top: 4px solid #888; border-color: #d32f2f;"> | ||
<section id="details" style="margin: 16px; padding: 16px; background: white; border: 2px solid #ccc; border-radius:8px;"> | ||
<p> | ||
All prerequisite reviews have been completed and you can now submit a | ||
request to create your origin trial. Click the "Request Trial Creation" | ||
button on the Origin Trial section of <a href="https://chromestatus.com/feature/1" | ||
>your feature's detail page</a>. | ||
</p> | ||
<p> | ||
<strong>Note:</strong> Only feature owners signed in with a | ||
"chromium.org" or "google.com" domain email address will have access to | ||
the trial creation form, and at least 1 Googler contact is required | ||
during form submission to continue the trial creation process. If you | ||
have any questions or need assistance, reach out to <a | ||
href="mailto:[email protected]" | ||
>[email protected]</a>. | ||
<br><br> | ||
Thanks,<br> | ||
Origin Trials team | ||
</p> | ||
</section> | ||
</div> | ||
</div> | ||
|
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,28 @@ | ||
{% import 'email-styles.html' as styles %} | ||
<div style="{{styles.body}}"> | ||
<div style="{{styles.branding}}">{{APP_TITLE}}</div> | ||
|
||
<div style="{{styles.content}} {{styles.content_alert}}"> | ||
<section id="details" style="{{styles.section}}"> | ||
<p> | ||
All prerequisite reviews have been completed and you can now submit a | ||
request to create your origin trial. Click the "Request Trial Creation" | ||
button on the Origin Trial section of <a href="{{chromestatus_url}}" | ||
>your feature's detail page</a>. | ||
</p> | ||
<p> | ||
<strong>Note:</strong> Only feature owners signed in with a | ||
"chromium.org" or "google.com" domain email address will have access to | ||
the trial creation form, and at least 1 Googler contact is required | ||
during form submission to continue the trial creation process. If you | ||
have any questions or need assistance, reach out to <a | ||
href="mailto:[email protected]" | ||
>[email protected]</a>. | ||
<br><br> | ||
Thanks,<br> | ||
Origin Trials team | ||
</p> | ||
</section> | ||
</div> | ||
</div> | ||
|
Oops, something went wrong.
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.