From f50243523f3b1bf9bffe59402177bc69b8c9d4b8 Mon Sep 17 00:00:00 2001
From: mlbonhomme <bonhomme@teklia.com>
Date: Tue, 9 Nov 2021 17:03:51 +0100
Subject: [PATCH] bunch of fixes

---
 .../test_transcriptions.py                    | 40 +++++++++++++++++--
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/tests/test_elements_worker/test_transcriptions.py b/tests/test_elements_worker/test_transcriptions.py
index 39e0420f..1583d447 100644
--- a/tests/test_elements_worker/test_transcriptions.py
+++ b/tests/test_elements_worker/test_transcriptions.py
@@ -791,6 +791,40 @@ def test_create_transcriptions_orientation(responses, mock_elements_worker_with_
         ],
     }
 
+    # Check that oriented transcriptions were properly stored in SQLite cache
+    assert list(CachedTranscription.select()) == [
+        CachedTranscription(id=UUID("00000000-0000-0000-0000-000000000000")),
+        CachedTranscription(id=UUID("11111111-1111-1111-1111-111111111111")),
+    ]
+    assert [
+        {
+            k: getattr(transcription, k)
+            for k in [
+                "id",
+                "text",
+                "confidence",
+                "orientation",
+                "worker_version_id",
+            ]
+        }
+        for transcription in CachedTranscription.select()
+    ] == [
+        {
+            "id": UUID("00000000-0000-0000-0000-000000000000"),
+            "text": "Animula vagula blandula",
+            "confidence": 0.12,
+            "orientation": TextOrientation.HorizontalRightToLeft.value,
+            "worker_version_id": UUID("12341234-1234-1234-1234-123412341234"),
+        },
+        {
+            "id": UUID("11111111-1111-1111-1111-111111111111"),
+            "text": "Hospes comesque corporis",
+            "confidence": 0.21,
+            "orientation": TextOrientation.VerticalLeftToRight.value,
+            "worker_version_id": UUID("12341234-1234-1234-1234-123412341234"),
+        },
+    ]
+
 
 def test_create_element_transcriptions_wrong_element(mock_elements_worker):
     with pytest.raises(AssertionError) as e:
@@ -1390,7 +1424,7 @@ def test_create_element_transcriptions_with_cache(
             element_id=UUID("11111111-1111-1111-1111-111111111111"),
             text="The",
             confidence=0.5,
-            orientation=TextOrientation.HorizontalLeftToRight,
+            orientation=TextOrientation.HorizontalLeftToRight.value,
             worker_version_id=UUID("12341234-1234-1234-1234-123412341234"),
         ),
         CachedTranscription(
@@ -1398,7 +1432,7 @@ def test_create_element_transcriptions_with_cache(
             element_id=UUID("22222222-2222-2222-2222-222222222222"),
             text="first",
             confidence=0.75,
-            orientation=TextOrientation.HorizontalLeftToRight,
+            orientation=TextOrientation.HorizontalLeftToRight.value,
             worker_version_id=UUID("12341234-1234-1234-1234-123412341234"),
         ),
         CachedTranscription(
@@ -1406,7 +1440,7 @@ def test_create_element_transcriptions_with_cache(
             element_id=UUID("11111111-1111-1111-1111-111111111111"),
             text="line",
             confidence=0.9,
-            orientation=TextOrientation.HorizontalLeftToRight,
+            orientation=TextOrientation.HorizontalLeftToRight.value,
             worker_version_id=UUID("12341234-1234-1234-1234-123412341234"),
         ),
     ]
-- 
GitLab