Skip to content

Commit

Permalink
Override settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilouf committed Dec 24, 2024
1 parent 541621f commit 9694bf7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lemarche/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from io import StringIO
from unittest.mock import patch

from django.test import TestCase
from django.test import TestCase, override_settings
from django.utils import timezone
from django.db.models import F
from django.core.management import call_command
Expand Down Expand Up @@ -168,6 +168,10 @@ def test_update_related_favorite_list_count_on_save(self):
self.assertEqual(user.favorite_list_count, 1)


@override_settings(
INACTIVE_USER_TIMEOUT_IN_MONTHS=12,
INACTIVE_USER_WARNING_DELAY_IN_DAYS=7,
)
class UserAnonymizationTestCase(TestCase):

def setUp(self):
Expand Down Expand Up @@ -237,7 +241,7 @@ def test_anonymize_command(self, mock_timezone):
mock_timezone.return_value = now_dt

out = StringIO()
call_command("anonymize_old_users", month_timeout=12, warning_delay=7, stdout=out)
call_command("anonymize_old_users", stdout=out)

self.assertEqual(User.objects.filter(is_active=False).count(), 2)
# fixme flag anonyme tout ca
Expand Down Expand Up @@ -268,7 +272,7 @@ def test_warn_command(self, mock_timezone):
mock_timezone.return_value = now_dt

out = StringIO()
call_command("anonymize_old_users", month_timeout=12, warning_delay=7, stdout=out)
call_command("anonymize_old_users", stdout=out)

log_qs = TemplateTransactionalSendLog.objects.all()
self.assertEqual(
Expand All @@ -277,7 +281,7 @@ def test_warn_command(self, mock_timezone):
)

# Called twice to veryfi that emails are not sent multiple times
call_command("anonymize_old_users", month_timeout=12, warning_delay=7, stdout=out)
call_command("anonymize_old_users", stdout=out)
log_qs = TemplateTransactionalSendLog.objects.all()
self.assertEqual(
log_qs.count(),
Expand All @@ -298,7 +302,7 @@ def test_dryrun_anonymize_command(self, mock_timezone):
original_qs_count = User.objects.filter(is_active=True).count()

out = StringIO()
call_command("anonymize_old_users", month_timeout=12, warning_delay=7, dry_run=True, stdout=out)
call_command("anonymize_old_users", dry_run=True, stdout=out)

self.assertEqual(original_qs_count, User.objects.filter(is_active=True).count())

Expand All @@ -312,6 +316,6 @@ def test_dryrun_warn_command(self, mock_timezone):
mock_timezone.return_value = now_dt

out = StringIO()
call_command("anonymize_old_users", month_timeout=12, warning_delay=7, dry_run=True, stdout=out)
call_command("anonymize_old_users", dry_run=True, stdout=out)

self.assertFalse(TemplateTransactionalSendLog.objects.all())

0 comments on commit 9694bf7

Please sign in to comment.