Skip to content

Commit

Permalink
CONCD-599 unit test for the Asset.get_ocr_transcript() method
Browse files Browse the repository at this point in the history
  • Loading branch information
rasarkar committed Apr 18, 2024
1 parent 61cc224 commit 6d0ec9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Binary file added concordia/tests/data/test-european.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions concordia/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from datetime import timedelta

import pytesseract
from django.test import TestCase
from django.utils import timezone
from PIL import Image

from concordia.models import Campaign, Transcription, UserProfileActivity
from concordia.utils import get_anonymous_user
Expand All @@ -20,6 +22,12 @@ def setUp(self):
reviewed_by=anon,
)

def get_ocr_transcript(self):
image = Image.open("concordia/tests/data/test-european.jpg")
phrase = "marrón rápido salta sobre el perro"
self.assertFalse(phrase in pytesseract.image_to_string(image))
self.assertTrue(phrase in pytesseract.image_to_string(image, lang="spa"))

def test_get_contributor_count(self):
self.assertEqual(self.asset.get_contributor_count(), 2)

Expand Down

0 comments on commit 6d0ec9f

Please sign in to comment.