Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80566694
test_word_position.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Sep 1, 10:23
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Sep 3, 10:23 (2 d)
Engine
blob
Format
Raw Data
Handle
20396375
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_word_position.py
View Options
import
unittest
from
os
import
sep
,
path
import
lxml.etree
as
ET
from
datatypes.matrix
import
Matrix
from
datatypes.word_position
import
WordPosition
class
TestWordPosition
(
unittest
.
TestCase
):
def
test_init
(
self
):
word_position
=
WordPosition
(
id
=
1
,
height
=
10
,
width
=
10
,
x
=
0
,
y
=
10
)
self
.
assertEqual
(
word_position
.
tag
,
WordPosition
.
TRANSKRIPTION
)
self
.
assertEqual
(
word_position
.
id
,
'1'
)
self
.
assertEqual
(
word_position
.
height
,
10
)
self
.
assertEqual
(
word_position
.
top
,
10
)
self
.
assertEqual
(
word_position
.
bottom
,
20
)
self
.
assertEqual
(
word_position
.
left
,
0
)
self
.
assertEqual
(
word_position
.
isOnTranskription
(),
True
)
self
.
assertEqual
(
word_position
.
isOnFaksimile
(),
False
)
def
test_attach_object_to_tree
(
self
):
matrix
=
Matrix
(
'matrix(0 0 0 0 0 0)'
)
word_position
=
WordPosition
(
id
=
1
,
height
=
10
,
width
=
10
,
x
=
0
,
y
=
10
,
matrix
=
matrix
,
tag
=
WordPosition
.
FAKSIMILE
)
empty_tree
=
ET
.
ElementTree
(
ET
.
Element
(
'page'
))
word_position
.
attach_object_to_tree
(
empty_tree
)
for
node
in
empty_tree
.
getroot
()
.
xpath
(
'//'
+
word_position
.
tag
):
self
.
assertEqual
(
node
.
get
(
'id'
),
'1'
)
self
.
assertEqual
(
node
.
get
(
'bottom'
),
'20'
)
self
.
assertEqual
(
node
.
get
(
'transform'
),
matrix
.
toString
())
self
.
assertEqual
(
node
.
get
(
'writing-process-id'
),
'-1'
)
word_position
=
WordPosition
(
node
=
empty_tree
.
getroot
()
.
find
(
'.//'
+
word_position
.
tag
))
def
test_get_semantic_dictionary
(
self
):
dictionary
=
WordPosition
.
get_semantic_dictionary
()
self
.
assertEqual
(
WordPosition
.
XML_TAG
in
dictionary
[
'properties'
]
.
get
(
'writing_process_id'
)
.
get
(
'xpath'
),
True
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Event Timeline
Log In to Comment