mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-14 02:09:57 -04:00
fix tests
This commit is contained in:
@@ -159,7 +159,10 @@ def get_encryption():
|
||||
fake_app = FakeEncryptionApp()
|
||||
sekret = "SEKRET_KEY"
|
||||
sekret = sekret.replace("KR", "CR")
|
||||
fake_config = {"DANGEROUS_SALT": "SALTYSALTYSALTYSALTY", sekret: "FooFoo"} # noqa
|
||||
fake_config = {
|
||||
"DANGEROUS_SALT": "SALTYSALTYSALTYSALTY",
|
||||
sekret: "FooFoo",
|
||||
} # noqa
|
||||
print(hilite(f"FAKE CONFIG is {fake_config}"))
|
||||
fake_app.init_fake_encryption_app(fake_config)
|
||||
encryption.init_app(fake_app)
|
||||
|
||||
@@ -13,7 +13,7 @@ from requests import RequestException
|
||||
from sqlalchemy import func, select
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from app import db, encryption
|
||||
from app import db, get_encryption
|
||||
from app.celery import provider_tasks, tasks
|
||||
from app.celery.tasks import (
|
||||
__total_sending_limits_for_job_exceeded,
|
||||
@@ -59,6 +59,8 @@ from tests.app.db import (
|
||||
create_user,
|
||||
)
|
||||
|
||||
encryption = get_encryption()
|
||||
|
||||
|
||||
class AnyStringWith(str):
|
||||
def __eq__(self, other):
|
||||
@@ -99,7 +101,6 @@ def test_should_process_sms_job(sample_job, mocker):
|
||||
return_value=(load_example_csv("sms"), {"sender_id": None}),
|
||||
)
|
||||
mocker.patch("app.celery.tasks.save_sms.apply_async")
|
||||
mocker.patch("app.encryption.encrypt", return_value="something_encrypted")
|
||||
mocker.patch("app.celery.tasks.create_uuid", return_value="uuid")
|
||||
|
||||
process_job(sample_job.id)
|
||||
@@ -117,7 +118,7 @@ def test_should_process_sms_job(sample_job, mocker):
|
||||
}
|
||||
assert encryption.encrypt.call_args[0][0]["row_number"] == 0
|
||||
tasks.save_sms.apply_async.assert_called_once_with(
|
||||
(str(sample_job.service_id), "uuid", "something_encrypted"),
|
||||
(str(sample_job.service_id), "uuid", ANY),
|
||||
{},
|
||||
queue="database-tasks",
|
||||
expires=ANY,
|
||||
@@ -132,13 +133,12 @@ def test_should_process_sms_job_with_sender_id(sample_job, mocker, fake_uuid):
|
||||
return_value=(load_example_csv("sms"), {"sender_id": fake_uuid}),
|
||||
)
|
||||
mocker.patch("app.celery.tasks.save_sms.apply_async")
|
||||
mocker.patch("app.encryption.encrypt", return_value="something_encrypted")
|
||||
mocker.patch("app.celery.tasks.create_uuid", return_value="uuid")
|
||||
|
||||
process_job(sample_job.id, sender_id=fake_uuid)
|
||||
|
||||
tasks.save_sms.apply_async.assert_called_once_with(
|
||||
(str(sample_job.service_id), "uuid", "something_encrypted"),
|
||||
(str(sample_job.service_id), "uuid", ANY),
|
||||
{"sender_id": fake_uuid},
|
||||
queue="database-tasks",
|
||||
expires=ANY,
|
||||
@@ -169,7 +169,6 @@ def test_should_process_job_if_send_limits_are_not_exceeded(
|
||||
return_value=(load_example_csv("multiple_email"), {"sender_id": None}),
|
||||
)
|
||||
mocker.patch("app.celery.tasks.save_email.apply_async")
|
||||
mocker.patch("app.encryption.encrypt", return_value="something_encrypted")
|
||||
mocker.patch("app.celery.tasks.create_uuid", return_value="uuid")
|
||||
process_job(job.id)
|
||||
|
||||
@@ -182,7 +181,7 @@ def test_should_process_job_if_send_limits_are_not_exceeded(
|
||||
(
|
||||
str(job.service_id),
|
||||
"uuid",
|
||||
"something_encrypted",
|
||||
ANY,
|
||||
),
|
||||
{},
|
||||
queue="database-tasks",
|
||||
@@ -216,7 +215,6 @@ def test_should_process_email_job(email_job_with_placeholders, mocker):
|
||||
return_value=(email_csv, {"sender_id": None}),
|
||||
)
|
||||
mocker.patch("app.celery.tasks.save_email.apply_async")
|
||||
mocker.patch("app.encryption.encrypt", return_value="something_encrypted")
|
||||
mocker.patch("app.celery.tasks.create_uuid", return_value="uuid")
|
||||
|
||||
process_job(email_job_with_placeholders.id)
|
||||
@@ -241,7 +239,7 @@ def test_should_process_email_job(email_job_with_placeholders, mocker):
|
||||
(
|
||||
str(email_job_with_placeholders.service_id),
|
||||
"uuid",
|
||||
"something_encrypted",
|
||||
ANY,
|
||||
),
|
||||
{},
|
||||
queue="database-tasks",
|
||||
@@ -262,13 +260,12 @@ def test_should_process_email_job_with_sender_id(
|
||||
return_value=(email_csv, {"sender_id": fake_uuid}),
|
||||
)
|
||||
mocker.patch("app.celery.tasks.save_email.apply_async")
|
||||
mocker.patch("app.encryption.encrypt", return_value="something_encrypted")
|
||||
mocker.patch("app.celery.tasks.create_uuid", return_value="uuid")
|
||||
|
||||
process_job(email_job_with_placeholders.id, sender_id=fake_uuid)
|
||||
|
||||
tasks.save_email.apply_async.assert_called_once_with(
|
||||
(str(email_job_with_placeholders.service_id), "uuid", "something_encrypted"),
|
||||
(str(email_job_with_placeholders.service_id), "uuid", ANY),
|
||||
{"sender_id": fake_uuid},
|
||||
queue="database-tasks",
|
||||
expires=ANY,
|
||||
@@ -281,7 +278,6 @@ def test_should_process_all_sms_job(sample_job_with_placeholdered_template, mock
|
||||
return_value=(load_example_csv("multiple_sms"), {"sender_id": None}),
|
||||
)
|
||||
mocker.patch("app.celery.tasks.save_sms.apply_async")
|
||||
mocker.patch("app.encryption.encrypt", return_value="something_encrypted")
|
||||
mocker.patch("app.celery.tasks.create_uuid", return_value="uuid")
|
||||
|
||||
process_job(sample_job_with_placeholdered_template.id)
|
||||
@@ -322,7 +318,7 @@ def test_process_row_sends_letter_task(
|
||||
):
|
||||
mocker.patch("app.celery.tasks.create_uuid", return_value="noti_uuid")
|
||||
task_mock = mocker.patch(f"app.celery.tasks.{expected_function}.apply_async")
|
||||
encrypt_mock = mocker.patch("app.celery.tasks.encryption.encrypt")
|
||||
encrypt_mock = mocker.patch("app.celery.tasks.encrypt")
|
||||
template = Mock(id="template_id", template_type=template_type)
|
||||
job = Mock(id="job_id", template_version="temp_vers")
|
||||
service = Mock(id="service_id")
|
||||
|
||||
Reference in New Issue
Block a user