From c5d3880c51c12e788fff61efabd57801e9120419 Mon Sep 17 00:00:00 2001 From: Rajit Sarkar Date: Wed, 31 Jul 2024 15:18:29 -0400 Subject: [PATCH 1/2] CONCD-824 changing output of method to match format expected by email template --- concordia/models.py | 8 ++++---- concordia/tasks.py | 8 -------- concordia/tests/test_models.py | 8 ++++---- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/concordia/models.py b/concordia/models.py index 580d286d1..d953f6ae6 100644 --- a/concordia/models.py +++ b/concordia/models.py @@ -42,22 +42,22 @@ def resource_file_upload_path(instance, filename): class ConcordiaUserManager(BaseUserManager): def review_incidents(self): - user_incident_count = {} + user_incident_count = [] for user in self.get_queryset().filter(is_superuser=False, is_staff=False): incident_count = user.review_incidents() if incident_count > 0: - user_incident_count[user.id] = incident_count + user_incident_count.append((user.id, user.username, incident_count)) return user_incident_count def transcribe_incidents(self): - user_incident_count = {} + user_incident_count = [] for user in self.get_queryset().filter(is_superuser=False, is_staff=False): incident_count = user.transcribe_incidents() if incident_count > 0: - user_incident_count[user.id] = incident_count + user_incident_count.append((user.id, user.username, incident_count)) return user_incident_count diff --git a/concordia/tasks.py b/concordia/tasks.py index 120ad3152..fbd33ab94 100644 --- a/concordia/tasks.py +++ b/concordia/tasks.py @@ -1044,14 +1044,6 @@ def fix_storage_images(campaign_slug=None, asset_start_id=None): logger.debug("%s / %s (%s%%)", count, full_count, str(count / full_count * 100)) -def transcribing_too_quickly(): - return Transcription.objects.transcribing_too_quickly() - - -def reviewing_too_quickly(): - return Transcription.objects.reviewing_too_quickly() - - @celery_app.task(ignore_result=True) def clear_sessions(): # This clears expired Django sessions in the database diff --git a/concordia/tests/test_models.py b/concordia/tests/test_models.py index 8a106095a..80c967332 100644 --- a/concordia/tests/test_models.py +++ b/concordia/tests/test_models.py @@ -77,7 +77,7 @@ def test_review_incidents(self): ) users = ConcordiaUser.objects.review_incidents() self.assertEqual(len(users), 1) - self.assertEqual(users[self.transcription1.reviewed_by.id], 1) + self.assertEqual(users[0][0], 3) create_transcription( asset=self.transcription1.asset, @@ -93,7 +93,7 @@ def test_review_incidents(self): ) users = ConcordiaUser.objects.review_incidents() self.assertEqual(len(users), 1) - self.assertEqual(users[self.transcription1.reviewed_by.id], 2) + self.assertEqual(users[0][0], 3) def test_transcribe_incidents(self): self.transcription1.submitted = timezone.now() @@ -124,7 +124,7 @@ def test_transcribe_incidents(self): ) users = ConcordiaUser.objects.transcribe_incidents() self.assertEqual(len(users), 1) - self.assertEqual(users[self.transcription1.user.id], 1) + self.assertEqual(users[0][0], 1) create_transcription( asset=self.transcription1.asset, @@ -133,7 +133,7 @@ def test_transcribe_incidents(self): ) users = ConcordiaUser.objects.transcribe_incidents() self.assertEqual(len(users), 1) - self.assertEqual(users[self.transcription1.user.id], 2) + self.assertEqual(users[0][0], 1) class AssetTestCase(CreateTestUsers, TestCase): From 29d2703c016acf4094c67e9e8c1dad9b252f2723 Mon Sep 17 00:00:00 2001 From: Rajit Sarkar Date: Wed, 31 Jul 2024 15:42:46 -0400 Subject: [PATCH 2/2] CONCD-824 updating unit tests --- concordia/tests/test_models.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/concordia/tests/test_models.py b/concordia/tests/test_models.py index 80c967332..ce064c94a 100644 --- a/concordia/tests/test_models.py +++ b/concordia/tests/test_models.py @@ -77,7 +77,14 @@ def test_review_incidents(self): ) users = ConcordiaUser.objects.review_incidents() self.assertEqual(len(users), 1) - self.assertEqual(users[0][0], 3) + self.assertEqual( + users[0], + ( + self.transcription1.reviewed_by.id, + self.transcription1.reviewed_by.username, + 1, + ), + ) create_transcription( asset=self.transcription1.asset, @@ -93,7 +100,14 @@ def test_review_incidents(self): ) users = ConcordiaUser.objects.review_incidents() self.assertEqual(len(users), 1) - self.assertEqual(users[0][0], 3) + self.assertEqual( + users[0], + ( + self.transcription1.reviewed_by.id, + self.transcription1.reviewed_by.username, + 2, + ), + ) def test_transcribe_incidents(self): self.transcription1.submitted = timezone.now() @@ -124,7 +138,10 @@ def test_transcribe_incidents(self): ) users = ConcordiaUser.objects.transcribe_incidents() self.assertEqual(len(users), 1) - self.assertEqual(users[0][0], 1) + self.assertEqual( + users[0], + (self.transcription1.user.id, self.transcription1.user.username, 1), + ) create_transcription( asset=self.transcription1.asset, @@ -133,7 +150,10 @@ def test_transcribe_incidents(self): ) users = ConcordiaUser.objects.transcribe_incidents() self.assertEqual(len(users), 1) - self.assertEqual(users[0][0], 1) + self.assertEqual( + users[0], + (self.transcription1.user.id, self.transcription1.user.username, 2), + ) class AssetTestCase(CreateTestUsers, TestCase):