Skip to content
Snippets Groups Projects

Text orientation in base worker

Merged ml bonhomme requested to merge text-orientation into master
All threads resolved!
1 file
+ 37
3
Compare changes
  • Side-by-side
  • Inline
@@ -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"),
),
]
Loading