Skip to content

Commit

Permalink
fixup!: start tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rgraber committed Aug 29, 2024
1 parent 6390b65 commit 53fe606
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kobo/apps/audit_log/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from kobo.apps.audit_log.models import AuditLog, AuditType
from kobo.celery import celery_app
from kpi.utils.log import logging
from django.conf import settings


BATCH_SIZE = 1000


@celery_app.task()
Expand All @@ -29,7 +30,7 @@ def spawn_access_log_cleaning_tasks():
.values_list('id', flat=True)
.iterator()
)
for id_batch in chunked(expired_logs, BATCH_SIZE):
for id_batch in chunked(expired_logs, settings.ACCESS_LOG_DELETION_BATCH_SIZE):
batch_delete_audit_logs_by_id.delay(ids=id_batch)


Expand Down
8 changes: 8 additions & 0 deletions kobo/apps/audit_log/tests/test_tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from kpi.tests.base_test_case import BaseTestCase
from unittest.mock import patch
from django.test import override_settings

class AuditLogTasksTestCase(BaseTestCase):
@override_settings(ACCESS_LOG_DELETION_BATCH_SIZE=2)
def test_spawn_new_tasks(self):
pass
2 changes: 2 additions & 0 deletions kobo/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,8 @@ def dj_stripe_request_callback_method():
'application/x-zip-compressed'
]

ACCESS_LOG_DELETION_BATCH_SIZE=1000

# Silence Django Guardian warning. Authentication backend is hooked, but
# Django Guardian does not recognize it because it is extended
SILENCED_SYSTEM_CHECKS = ['guardian.W001']

0 comments on commit 53fe606

Please sign in to comment.