Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91237847
test_reference.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, Nov 9, 06:22
Size
2 KB
Mime Type
text/x-python
Expires
Mon, Nov 11, 06:22 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22227086
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_reference.py
View Options
import
unittest
from
os
import
sep
,
path
import
lxml.etree
as
ET
import
sys
sys
.
path
.
append
(
'svgscripts'
)
from
datatypes.reference
import
Reference
class
TestReference
(
unittest
.
TestCase
):
def
test_init
(
self
):
reference_string
=
'5'
reference
=
Reference
.
create_cls
(
reference_string
=
reference_string
,
title
=
'ASDF'
)
self
.
assertEqual
(
reference
.
first_line
,
5
)
reference_string
=
'5,5'
reference
=
Reference
.
create_cls
(
reference_string
=
reference_string
,
title
=
'ASDF'
)
self
.
assertEqual
(
reference
.
first_line
,
5
)
self
.
assertEqual
(
reference
.
page_number
,
str
(
5
))
reference_string
=
'ASDF 5,5-8'
reference
=
Reference
.
create_cls
(
reference_string
=
reference_string
)
self
.
assertEqual
(
reference
.
title
,
'ASDF'
)
self
.
assertEqual
(
reference
.
first_line
,
5
)
self
.
assertEqual
(
reference
.
last_line
,
8
)
self
.
assertEqual
(
reference
.
page_number
,
str
(
5
))
reference_string
=
'ASDF 5,5 a .'
reference
=
Reference
.
create_cls
(
reference_string
=
reference_string
)
self
.
assertEqual
(
reference
.
page_number
,
str
(
5
))
def
test_attach_create
(
self
):
reference_string
=
'ASDF 5,5-8'
reference
=
Reference
.
create_cls
(
is_uncertain
=
True
,
reference_string
=
reference_string
)
empty_tree
=
ET
.
ElementTree
(
ET
.
Element
(
'page'
))
reference
.
attach_object_to_tree
(
empty_tree
)
#print(ET.dump(empty_tree.getroot()))
nodes
=
empty_tree
.
xpath
(
'//'
+
Reference
.
XML_TAG
)
self
.
assertEqual
(
len
(
nodes
),
1
)
reference_copy
=
Reference
.
create_cls
(
node
=
nodes
[
0
])
self
.
assertEqual
(
reference
.
id
,
reference_copy
.
id
)
self
.
assertEqual
(
reference
.
is_uncertain
,
reference_copy
.
is_uncertain
)
self
.
assertEqual
(
reference
.
title
,
reference_copy
.
title
)
self
.
assertEqual
(
reference
.
page_number
,
reference_copy
.
page_number
)
self
.
assertEqual
(
reference
.
first_line
,
reference_copy
.
first_line
)
self
.
assertEqual
(
reference
.
last_line
,
reference_copy
.
last_line
)
def
test_get_semantic_dictionary
(
self
):
dictionary
=
Reference
.
get_semantic_dictionary
()
#print(dictionary)
def
test_toString
(
self
):
reference_string
=
'ASDF 5,5-8'
reference
=
Reference
.
create_cls
(
is_uncertain
=
True
,
reference_string
=
reference_string
)
self
.
assertEqual
(
reference
.
toString
(),
reference_string
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Event Timeline
Log In to Comment