Skip to content

Commit

Permalink
Merge pull request #1462 from sul-dlss/t1450-new-oclc-email
Browse files Browse the repository at this point in the history
Adds library to OCLC New MARC errors subject-line
  • Loading branch information
jgreben authored Dec 2, 2024
2 parents 00b5f20 + fb218c9 commit 389817e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libsys_airflow/plugins/data_exports/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,18 @@ def generate_oclc_new_marc_errors_email(error_reports: dict):
if not airflow_url.endswith("/"):
airflow_url = f"{airflow_url}/"

subject_line = "OCLC: MARC Errors for New Record"
subject_template = "OCLC: MARC Errors for New Record"

for library, report in error_reports.items():
to_emails = [
devs_email,
]

_match_oclc_library(
to_emails, subject_line = _match_oclc_library(
library=library,
to_emails=to_emails,
cohort_emails=cohort_emails,
subject_line=subject_line,
subject_line=subject_template,
)

if not is_production():
Expand Down
23 changes: 23 additions & 0 deletions tests/data_exports/test_data_exports_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from libsys_airflow.plugins.data_exports.email import (
generate_multiple_oclc_identifiers_email,
generate_oclc_new_marc_errors_email,
failed_transmission_email,
)

Expand Down Expand Up @@ -185,6 +186,28 @@ def test_failed_transmission_email(mocker, mock_dag_run, mock_folio_variables, c
)


def test_generate_oclc_new_marc_errors_email(
mocker, mock_dag_run, mock_folio_variables
):
mock_send_email = mocker.patch(
"libsys_airflow.plugins.data_exports.email.send_email_with_server_name"
)

error_reports = {
"STF": "/opt/airflow/data-export-files/oclc/reports/STF/new_marc_errors/2024-11-26T23:26:11.316254.html",
"HIN": "/opt/airflow/data-export-files/oclc/reports/HIN/new_marc_errors/2024-11-26T23:26:12.316254.html",
"S7Z": "/opt/airflow/data-export-files/oclc/reports/S7Z/new_marc_errors/2024-11-26T23:26:12.316254.html",
}

generate_oclc_new_marc_errors_email(error_reports)

assert mock_send_email.call_count == 3

assert mock_send_email.call_args_list[0][1]["subject"].endswith("SUL")
assert mock_send_email.call_args_list[1][1]["subject"].endswith("Hoover")
assert mock_send_email.call_args_list[2][1]["subject"].endswith("Business")


def test_failed_full_dump_transmission_email(
mocker, mock_dag_run, mock_folio_variables
):
Expand Down

0 comments on commit 389817e

Please sign in to comment.