diff --git a/notebooks/scenarios/bigquery/040-do-review-requests.ipynb b/notebooks/scenarios/bigquery/040-do-review-requests.ipynb index 8acc4e55274..08eb24f2fda 100644 --- a/notebooks/scenarios/bigquery/040-do-review-requests.ipynb +++ b/notebooks/scenarios/bigquery/040-do-review-requests.ipynb @@ -19,6 +19,7 @@ "outputs": [], "source": [ "# stdlib\n", + "from collections import Counter\n", "import random\n", "\n", "# syft absolute\n", @@ -220,9 +221,46 @@ "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", + " job.user_email for job in submitted_jobs_data_should_fail\n", + ")\n", + "\n", + "expected_approved_email_counts = Counter(\n", + " job.user_email for job in submitted_jobs_data_should_succeed\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# if user's email notifications are enabled,\n", + "# 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" ] }, { @@ -293,6 +331,11 @@ } ], "metadata": { + "kernelspec": { + "display_name": "syft", + "language": "python", + "name": "python3" + }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -303,7 +346,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.5" + "version": "3.12.4" } }, "nbformat": 4,