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
9ff5dcdd
Commit
9ff5dcdd
authored
3 years ago
by
ml bonhomme
Browse files
Options
Downloads
Patches
Plain Diff
partial/update text orientation
parent
3b78a2c8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/migrations/0045_transcription_orientation.py
+0
-21
0 additions, 21 deletions
...ex/documents/migrations/0045_transcription_orientation.py
arkindex/documents/tests/test_edit_transcriptions.py
+82
-0
82 additions, 0 deletions
arkindex/documents/tests/test_edit_transcriptions.py
with
82 additions
and
21 deletions
arkindex/documents/migrations/0045_transcription_orientation.py
deleted
100644 → 0
+
0
−
21
View file @
3b78a2c8
# Generated by Django 3.2.6 on 2021-10-22 08:27
import
enumfields.fields
from
django.db
import
migrations
import
arkindex.documents.models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
documents
'
,
'
0044_remove_metadata_index
'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'
transcription
'
,
name
=
'
orientation
'
,
field
=
enumfields
.
fields
.
EnumField
(
default
=
'
horizontal-lr
'
,
enum
=
arkindex
.
documents
.
models
.
TextOrientation
,
max_length
=
50
),
),
]
This diff is collapsed.
Click to expand it.
arkindex/documents/tests/test_edit_transcriptions.py
+
82
−
0
View file @
9ff5dcdd
...
...
@@ -149,6 +149,88 @@ class TestEditTranscription(FixtureAPITestCase):
'
worker_version_id
'
:
None
,
})
def
test_transcription_patch_orientation
(
self
):
"""
Assert it is possible to edit only the text orientation
"""
self
.
client
.
force_login
(
self
.
user
)
manual_tr_id
=
self
.
manual_transcription
.
id
response
=
self
.
client
.
patch
(
reverse
(
'
api:transcription-edit
'
,
kwargs
=
{
'
pk
'
:
manual_tr_id
}),
format
=
'
json
'
,
data
=
{
'
orientation
'
:
'
vertical-rl
'
}
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
manual_transcription
.
refresh_from_db
()
self
.
assertDictEqual
(
response
.
json
(),
{
'
id
'
:
str
(
manual_tr_id
),
'
confidence
'
:
None
,
'
score
'
:
None
,
'
text
'
:
'
A manual transcription
'
,
'
orientation
'
:
'
vertical-rl
'
,
'
worker_version_id
'
:
None
,
})
def
test_transcription_patch_invalid_orientation
(
self
):
"""
An invalid text orientation value causes an error
"""
self
.
client
.
force_login
(
self
.
user
)
manual_tr_id
=
self
.
manual_transcription
.
id
response
=
self
.
client
.
patch
(
reverse
(
'
api:transcription-edit
'
,
kwargs
=
{
'
pk
'
:
manual_tr_id
}),
format
=
'
json
'
,
data
=
{
'
orientation
'
:
'
wobbly
'
}
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
self
.
assertEqual
(
response
.
json
(),
{
'
orientation
'
:
[
'
Value is not of type TextOrientation
'
]})
def
test_transcription_edit_orientation
(
self
):
"""
Assert it is possible to edit the text orientation with UpdateTranscription
"""
self
.
client
.
force_login
(
self
.
user
)
manual_tr_id
=
self
.
manual_transcription
.
id
response
=
self
.
client
.
put
(
reverse
(
'
api:transcription-edit
'
,
kwargs
=
{
'
pk
'
:
manual_tr_id
}),
format
=
'
json
'
,
data
=
{
'
text
'
:
'
a knight was living lonely
'
,
'
orientation
'
:
'
vertical-rl
'
,
}
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
manual_transcription
.
refresh_from_db
()
self
.
assertDictEqual
(
response
.
json
(),
{
'
id
'
:
str
(
manual_tr_id
),
'
confidence
'
:
None
,
'
score
'
:
None
,
'
text
'
:
'
a knight was living lonely
'
,
'
orientation
'
:
'
vertical-rl
'
,
'
worker_version_id
'
:
None
,
})
def
test_transcription_edit_invalid_orientation
(
self
):
"""
An invalid text orientation value causes an error
"""
self
.
client
.
force_login
(
self
.
user
)
manual_tr_id
=
self
.
manual_transcription
.
id
response
=
self
.
client
.
put
(
reverse
(
'
api:transcription-edit
'
,
kwargs
=
{
'
pk
'
:
manual_tr_id
}),
format
=
'
json
'
,
data
=
{
'
text
'
:
'
a knight was living lonely
'
,
'
orientation
'
:
'
wobbly
'
,
}
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
self
.
assertEqual
(
response
.
json
(),
{
'
orientation
'
:
[
'
Value is not of type TextOrientation
'
]})
def
test_transcription_patch_write_right
(
self
):
"""
A write right is required to patch a manual transcription
...
...
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