Skip to content
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

Check that users receive approved / reject emails in bigquery L2 notebook #9328

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
updated email check
  • Loading branch information
BrendanSchell committed Sep 27, 2024
commit f5b5b7b5fd51a11d32ddaa10e71a84f6b8fd2326
49 changes: 45 additions & 4 deletions notebooks/scenarios/bigquery/040-do-review-requests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"outputs": [],
"source": [
"# stdlib\n",
"from collections import Counter\n",
"import random\n",
"\n",
"# syft absolute\n",
Expand Down Expand Up @@ -220,9 +221,44 @@
"metadata": {},
"outputs": [],
"source": [
"# for user_email, new_count in new_n_emails_per_job_user.items():\n",
"# old_count = n_emails_per_job_user[user_email]\n",
"# assert new_count > old_count"
"job_emails = get_job_emails(submitted_jobs_data, high_client, email_server)\n",
"rejected_email_counts = {\n",
" k: sum(\"rejected\" in email[\"email_content\"].lower() for email in v)\n",
" for k, v in job_emails.items()\n",
"}\n",
"approved_email_counts = {\n",
" k: sum(\"approved\" in email[\"email_content\"].lower() for email in v)\n",
" for k, v in job_emails.items()\n",
"}\n",
"expected_rejected_email_counts = Counter(\n",
" map(lambda x: x.user_email, submitted_jobs_data_should_fail)\n",
")\n",
"expected_approved_email_counts = Counter(\n",
" map(lambda x: x.user_email, submitted_jobs_data_should_succeed)\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# if user's email notifications are enabled, should have received either approved or rejected email\n",
"for user_email, new_count in new_n_emails_per_job_user.items():\n",
" user = [u for u in users if u.email == user_email][0]\n",
" old_count = n_emails_per_job_user[user_email]\n",
" if not user.email_disabled:\n",
" # greater than or equal to since duplicates can happen\n",
" assert new_count > old_count\n",
" assert rejected_email_counts.get(\n",
" user_email, 0\n",
" ) >= expected_rejected_email_counts.get(user_email, 0)\n",
" assert approved_email_counts.get(\n",
" user_email, 0\n",
" ) >= expected_approved_email_counts.get(user_email, 0)\n",
" else:\n",
" assert new_count == old_count"
]
},
{
Expand Down Expand Up @@ -293,6 +329,11 @@
}
],
"metadata": {
"kernelspec": {
"display_name": "syft",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
Expand All @@ -303,7 +344,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.5"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down