Skip to content

Commit

Permalink
CONCD-824 changing output of method (#2478)
Browse files Browse the repository at this point in the history
* CONCD-824 changing output of method to match format expected by email template

* CONCD-824 updating unit tests
  • Loading branch information
rasarkar authored Aug 1, 2024
1 parent 0a049aa commit 8b035dc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
8 changes: 4 additions & 4 deletions concordia/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 0 additions & 8 deletions concordia/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 24 additions & 4 deletions concordia/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ 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],
(
self.transcription1.reviewed_by.id,
self.transcription1.reviewed_by.username,
1,
),
)

create_transcription(
asset=self.transcription1.asset,
Expand All @@ -93,7 +100,14 @@ 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],
(
self.transcription1.reviewed_by.id,
self.transcription1.reviewed_by.username,
2,
),
)

def test_transcribe_incidents(self):
self.transcription1.submitted = timezone.now()
Expand Down Expand Up @@ -124,7 +138,10 @@ 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],
(self.transcription1.user.id, self.transcription1.user.username, 1),
)

create_transcription(
asset=self.transcription1.asset,
Expand All @@ -133,7 +150,10 @@ 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],
(self.transcription1.user.id, self.transcription1.user.username, 2),
)


class AssetTestCase(CreateTestUsers, TestCase):
Expand Down

0 comments on commit 8b035dc

Please sign in to comment.