diff --git a/src/app/mork/conf.py b/src/app/mork/conf.py index c8e0dd1..78c9c66 100644 --- a/src/app/mork/conf.py +++ b/src/app/mork/conf.py @@ -28,10 +28,10 @@ class Settings(BaseSettings): API_KEYS: list[str] = ["APIKeyToBeChanged"] # Warning task configuration - WARNING_PERIOD: timedelta = "P3Y30D" + WARNING_PERIOD: timedelta = "P5Y30D" # Deletion task configuration - DELETION_PERIOD: timedelta = "P3Y" + DELETION_PERIOD: timedelta = "P5Y" DELETE_MAX_RETRIES: int = 3 # Edx forum configuration diff --git a/src/app/mork/tests/celery/tasks/test_deletion.py b/src/app/mork/tests/celery/tasks/test_deletion.py index a2b5d68..954445b 100644 --- a/src/app/mork/tests/celery/tasks/test_deletion.py +++ b/src/app/mork/tests/celery/tasks/test_deletion.py @@ -14,6 +14,7 @@ mark_user_for_deletion, remove_email_status, ) +from mork.conf import settings from mork.edx.mysql.factories.auth import EdxAuthUserFactory from mork.exceptions import UserDeleteError from mork.factories.tasks import EmailStatusFactory @@ -28,22 +29,22 @@ def test_delete_inactive_users(edx_mysql_db, monkeypatch): """Test the `delete_inactive_users` function.""" - # 2 users that did not log in for 3 years + # 2 users that did not log in for more than the deletion period EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.DELETION_PERIOD), email="johndoe1@example.com", ) EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.DELETION_PERIOD), email="johndoe2@example.com", ) # 2 users that logged in recently EdxAuthUserFactory.create( - last_login=Faker().date_time_between(start_date="-3y"), + last_login=Faker().date_time_between(start_date=-settings.DELETION_PERIOD), email="janedah1@example.com", ) EdxAuthUserFactory.create( - last_login=Faker().date_time_between(start_date="-3y"), + last_login=Faker().date_time_between(start_date=-settings.DELETION_PERIOD), email="janedah2@example.com", ) @@ -68,13 +69,13 @@ def test_delete_inactive_users(edx_mysql_db, monkeypatch): def test_delete_inactive_users_with_limit(edx_mysql_db, monkeypatch): """Test the `delete_inactive_users` function with limit.""" - # 2 users that did not log in for 3 years + # 2 users that did not log in for more than the deletion period EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.DELETION_PERIOD), email="johndoe1@example.com", ) EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.DELETION_PERIOD), email="johndoe2@example.com", ) @@ -98,13 +99,13 @@ def test_delete_inactive_users_with_limit(edx_mysql_db, monkeypatch): def test_delete_inactive_users_with_batch_size(edx_mysql_db, monkeypatch): """Test the `warn_inactive_users` function with batch size.""" - # 2 users that did not log in for 3 years + # 2 users that did not log in for more than the deletion period EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.DELETION_PERIOD), email="johndoe1@example.com", ) EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.DELETION_PERIOD), email="johndoe2@example.com", ) @@ -144,13 +145,13 @@ def test_delete_inactive_users_with_batch_size(edx_mysql_db, monkeypatch): def test_delete_inactive_users_with_dry_run(edx_mysql_db, monkeypatch): """Test the `delete_inactive_users` function with dry run activated (by default).""" - # 2 users that did not log in for 3 years + # 2 users that did not log in for more than the deletion period EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.DELETION_PERIOD), email="johndoe1@example.com", ) EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.DELETION_PERIOD), email="johndoe2@example.com", ) diff --git a/src/app/mork/tests/celery/tasks/test_emailing.py b/src/app/mork/tests/celery/tasks/test_emailing.py index c3e6436..db389cf 100644 --- a/src/app/mork/tests/celery/tasks/test_emailing.py +++ b/src/app/mork/tests/celery/tasks/test_emailing.py @@ -11,6 +11,7 @@ warn_inactive_users, warn_user, ) +from mork.conf import settings from mork.edx.mysql.factories.auth import EdxAuthUserFactory from mork.exceptions import EmailAlreadySent, EmailSendError from mork.factories.tasks import EmailStatusFactory @@ -18,25 +19,25 @@ def test_warn_inactive_users(edx_mysql_db, monkeypatch): """Test the `warn_inactive_users` function.""" - # 2 users that did not log in for 3 years + # 2 users that did not log in for more than the warning period EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.WARNING_PERIOD), username="JohnDoe1", email="johndoe1@example.com", ) EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.WARNING_PERIOD), username="JohnDoe2", email="johndoe2@example.com", ) # 2 users that logged in recently EdxAuthUserFactory.create( - last_login=Faker().date_time_between(start_date="-3y"), + last_login=Faker().date_time_between(start_date=-settings.WARNING_PERIOD), username="JaneDah1", email="janedah1@example.com", ) EdxAuthUserFactory.create( - last_login=Faker().date_time_between(start_date="-3y"), + last_login=Faker().date_time_between(start_date=-settings.WARNING_PERIOD), username="JaneDah2", email="janedah2@example.com", ) @@ -66,14 +67,14 @@ def test_warn_inactive_users(edx_mysql_db, monkeypatch): def test_warn_inactive_users_with_limit(edx_mysql_db, monkeypatch): """Test the `warn_inactive_users` function with limit.""" - # 2 users that did not log in for 3 years + # 2 users that did not log in for more than the warning period EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.WARNING_PERIOD), username="JohnDoe1", email="johndoe1@example.com", ) EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.WARNING_PERIOD), username="JohnDoe2", email="johndoe2@example.com", ) @@ -100,14 +101,14 @@ def test_warn_inactive_users_with_limit(edx_mysql_db, monkeypatch): def test_warn_inactive_users_with_batch_size(edx_mysql_db, monkeypatch): """Test the `warn_inactive_users` function with batch size.""" - # 2 users that did not log in for 3 years + # 2 users that did not log in for more than the warning period EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.WARNING_PERIOD), username="JohnDoe1", email="johndoe1@example.com", ) EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.WARNING_PERIOD), username="JohnDoe2", email="johndoe2@example.com", ) @@ -152,14 +153,14 @@ def test_warn_inactive_users_with_batch_size(edx_mysql_db, monkeypatch): def test_warn_inactive_users_with_dry_run(edx_mysql_db, monkeypatch): """Test the `warn_inactive_users` function with dry run activated (by default).""" - # 2 users that did not log in for 3 years + # 2 users that did not log in for more than the warning period EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.WARNING_PERIOD), username="JohnDoe1", email="johndoe1@example.com", ) EdxAuthUserFactory.create( - last_login=Faker().date_time_between(end_date="-3y"), + last_login=Faker().date_time_between(end_date=-settings.WARNING_PERIOD), username="JohnDoe2", email="johndoe2@example.com", )