-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs. TILA-2888
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import datetime | ||
|
||
import pytest | ||
from django.test import override_settings | ||
|
||
from tests.factories import ApplicationFactory, ApplicationRoundFactory | ||
from tilavarauspalvelu.models import Application | ||
from tilavarauspalvelu.tasks import delete_expired_applications | ||
from utils.date_utils import local_date | ||
|
||
pytestmark = [ | ||
pytest.mark.django_db, | ||
] | ||
|
||
|
||
@override_settings(REMOVE_EXPIRED_APPLICATIONS_OLDER_THAN_DAYS=365) | ||
def test_delete_expired_applications(): | ||
application_round_old = ApplicationRoundFactory.create_in_status_results_sent( | ||
application_period_end=local_date() - datetime.timedelta(days=365) | ||
) | ||
application_sent = ApplicationFactory.create_in_status_results_sent(application_round=application_round_old) # Kept | ||
ApplicationFactory.create_in_status_expired(application_round=application_round_old) # Deleted | ||
ApplicationFactory.create_in_status_cancelled(application_round=application_round_old) # Deleted | ||
|
||
application_round_new = ApplicationRoundFactory.create_in_status_results_sent( | ||
application_period_end=local_date() - datetime.timedelta(days=364) # Not old enough to delete applications | ||
) | ||
application_new = ApplicationFactory.create_in_status_expired(application_round=application_round_new) # Kept | ||
|
||
delete_expired_applications() | ||
|
||
applications = Application.objects.all().order_by("application_round") | ||
assert len(applications) == 2 | ||
assert list(applications) == [application_sent, application_new] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters