Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F84220713
test_line.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
Sat, Sep 21, 11:06
Size
1 KB
Mime Type
text/x-python
Expires
Mon, Sep 23, 11:06 (2 d)
Engine
blob
Format
Raw Data
Handle
20898253
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_line.py
View Options
import
unittest
from
os
import
sep
,
path
from
os.path
import
isdir
,
dirname
import
lxml.etree
as
ET
import
sys
import
sys
sys
.
path
.
append
(
'svgscripts'
)
from
datatypes.line
import
Line
from
datatypes.line_continuation
import
LineContinuation
class
TestLineNumber
(
unittest
.
TestCase
):
def
setUp
(
self
):
DATADIR
=
dirname
(
__file__
)
+
sep
+
'test_data'
self
.
test_target_file
=
DATADIR
+
sep
+
'test.xml'
self
.
id
=
24
def
test_init
(
self
):
lnr
=
Line
(
id
=
self
.
id
)
self
.
assertEqual
(
lnr
.
id
,
self
.
id
)
def
test_init_from_xml
(
self
):
xml_tree
=
ET
.
parse
(
self
.
test_target_file
)
lines
=
[
Line
.
create_cls_from_node
(
node
=
node
)
for
node
in
xml_tree
.
getroot
()
.
xpath
(
Line
.
XML_TAG
)
]
self
.
assertEqual
(
len
(
lines
),
49
)
self
.
assertEqual
(
lines
[
0
]
.
id
,
1
)
self
.
assertEqual
(
lines
[
48
]
.
id
,
49
)
def
test_get_semanticAndDataDict
(
self
):
#print(Line.get_semantic_dictionary())
pass
def
test_attach
(
self
):
tree
=
ET
.
Element
(
'page'
)
xml_tree
=
ET
.
parse
(
self
.
test_target_file
)
line
=
[
Line
.
create_cls_from_node
(
node
=
node
)
for
node
in
xml_tree
.
getroot
()
.
xpath
(
Line
.
XML_TAG
)
][
1
]
line
.
editor_comments
.
append
(
LineContinuation
.
create_cls
(
'1,3'
))
line
.
editor_comments
.
append
(
LineContinuation
.
create_cls
(
'1,3'
))
line
.
attach_object_to_tree
(
tree
)
lineB
=
[
Line
.
create_cls_from_node
(
node
=
node
)
for
node
in
tree
.
xpath
(
Line
.
XML_TAG
)
][
0
]
self
.
assertEqual
(
lineB
.
id
,
line
.
id
)
self
.
assertEqual
(
lineB
.
editor_comments
[
0
]
.
reference
.
first_line
,
line
.
editor_comments
[
0
]
.
reference
.
first_line
)
self
.
assertEqual
(
len
(
lineB
.
editor_comments
),
2
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Event Timeline
Log In to Comment