Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63028379
test_faksimile_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
Fri, May 17, 06:51
Size
2 KB
Mime Type
text/x-python
Expires
Sun, May 19, 06:51 (2 d)
Engine
blob
Format
Raw Data
Handle
17677667
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_faksimile_position.py
View Options
import
unittest
from
os
import
sep
,
path
import
lxml.etree
as
ET
import
sys
sys
.
path
.
append
(
'svgscripts'
)
from
datatypes.faksimile_image
import
FaksimileImage
from
datatypes.matrix
import
Matrix
from
datatypes.word_position
import
WordPosition
from
datatypes.faksimile_position
import
FaksimilePosition
from
datatypes.text_field
import
TextField
class
TestWordPosition
(
unittest
.
TestCase
):
def
test_init
(
self
):
faksimile_position
=
FaksimilePosition
(
id
=
1
,
height
=
10
,
width
=
10
,
x
=
0
,
y
=
10
)
self
.
assertEqual
(
faksimile_position
.
id
,
'1'
)
self
.
assertEqual
(
faksimile_position
.
height
,
10
)
self
.
assertEqual
(
faksimile_position
.
top
,
10
)
self
.
assertEqual
(
faksimile_position
.
bottom
,
20
)
self
.
assertEqual
(
faksimile_position
.
left
,
0
)
def
test_attach_object_to_tree
(
self
):
matrix
=
Matrix
(
'matrix(0 0 0 0 0 0)'
)
faksimile_position
=
FaksimilePosition
(
id
=
1
,
height
=
10
,
width
=
10
,
x
=
0
,
y
=
10
,
matrix
=
matrix
)
empty_tree
=
ET
.
ElementTree
(
ET
.
Element
(
'page'
))
faksimile_position
.
attach_object_to_tree
(
empty_tree
)
for
node
in
empty_tree
.
getroot
()
.
xpath
(
'//'
+
faksimile_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'
)
faksimile_position
=
FaksimilePosition
(
node
=
empty_tree
.
getroot
()
.
find
(
'.//'
+
faksimile_position
.
tag
))
def
test_get_semantic_dictionary
(
self
):
dictionary
=
FaksimilePosition
.
get_semantic_dictionary
()
#print(dictionary)
def
test_create_list_of_cls
(
self
):
other_list
=
[
WordPosition
(
id
=
1
,
height
=
10
,
width
=
10
,
x
=
0
,
y
=
10
)
]
faksimile_positions
=
FaksimilePosition
.
create_list_of_cls
(
other_list
,
FaksimileImage
(),
TextField
())
self
.
assertEqual
(
faksimile_positions
[
0
]
!=
other_list
[
0
],
True
)
self
.
assertEqual
(
type
(
faksimile_positions
[
0
]),
FaksimilePosition
)
self
.
assertEqual
(
faksimile_positions
[
0
]
.
faksimile_image
is
not
None
,
True
)
self
.
assertEqual
(
faksimile_positions
[
0
]
.
text_field
is
not
None
,
True
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Event Timeline
Log In to Comment