Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
89024a99
Commit
89024a99
authored
6 years ago
by
Erwan Rouchet
Browse files
Options
Downloads
Patches
Plain Diff
Add bulk_transcriptions unit test
parent
d284bbfe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!22
Add score to transcriptions
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex/images/tests.py
+55
-0
55 additions, 0 deletions
arkindex/images/tests.py
with
55 additions
and
0 deletions
arkindex/images/tests.py
0 → 100644
+
55
−
0
View file @
89024a99
from
django.test
import
TestCase
from
arkindex.documents.models
import
Page
from
arkindex.images.models
import
ImageServer
,
Image
,
Zone
,
Transcription
from
arkindex.images.importer
import
bulk_transcriptions
class
TestBulkTranscriptions
(
TestCase
):
"""
Tests for bulk transcription and zone importing
"""
def
setUp
(
self
):
# Create a page and an image
self
.
imgsrv
=
ImageServer
.
objects
.
create
(
name
=
"
Test Server
"
,
url
=
"
http://server
"
)
self
.
img
=
Image
.
objects
.
create
(
path
=
'
img
'
,
width
=
1337
,
height
=
42
,
server
=
self
.
imgsrv
)
self
.
page
=
Page
.
objects
.
create
(
name
=
"
page
"
,
folio
=
"
page
"
)
Zone
.
objects
.
create
(
polygon
=
[[
0
,
0
],
[
1337
,
0
],
[
1337
,
42
],
[
42
,
0
]],
image
=
self
.
img
,
element
=
self
.
page
)
def
test_bulk_transcriptions
(
self
):
items
=
[
{
'
x
'
:
0
,
'
y
'
:
0
,
'
width
'
:
100
,
'
height
'
:
100
,
'
line
'
:
'
1
'
,
'
text
'
:
'
test 1
'
,
'
score
'
:
0.1
,
},
{
'
x
'
:
20
,
'
y
'
:
20
,
'
width
'
:
100
,
'
height
'
:
100
,
'
line
'
:
'
2
'
,
'
text
'
:
'
test 2
'
,
'
score
'
:
0.2
,
},
]
out
=
list
(
bulk_transcriptions
(
self
.
img
,
self
.
page
,
items
))
out
.
sort
(
key
=
lambda
t
:
t
.
line
)
# Prevent test errors by sorting
self
.
assertEqual
(
len
(
out
),
2
)
self
.
assertIsInstance
(
out
[
0
],
Transcription
)
self
.
assertIsInstance
(
out
[
1
],
Transcription
)
self
.
assertEqual
(
out
[
0
].
line
,
1
)
self
.
assertEqual
(
out
[
0
].
text
,
'
test 1
'
)
self
.
assertEqual
(
out
[
0
].
score
,
0.1
)
self
.
assertEqual
(
out
[
1
].
line
,
2
)
self
.
assertEqual
(
out
[
1
].
text
,
'
test 2
'
)
self
.
assertEqual
(
out
[
1
].
score
,
0.2
)
self
.
assertEqual
(
out
[
0
].
zones
.
count
(),
1
)
self
.
assertEqual
(
out
[
1
].
zones
.
count
(),
1
)
z1
,
z2
=
out
[
0
].
zones
.
first
(),
out
[
1
].
zones
.
first
()
self
.
assertListEqual
(
z1
.
polygon
,
[[
0
,
0
],
[
0
,
100
],
[
100
,
100
],
[
100
,
0
]])
self
.
assertListEqual
(
z2
.
polygon
,
[[
20
,
20
],
[
20
,
120
],
[
120
,
120
],
[
120
,
20
]])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment