Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61813109
test_writing_process.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
Thu, May 9, 03:19
Size
1 KB
Mime Type
text/x-python
Expires
Sat, May 11, 03:19 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17541939
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_writing_process.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'
)
dir_changed
=
False
if
not
isdir
(
'datatypes'
):
sys
.
path
.
append
(
dirname
(
sys
.
path
[
0
]))
dir_changed
=
True
from
datatypes.writing_process
import
WritingProcess
class
TestWritingProcess
(
unittest
.
TestCase
):
def
setUp
(
self
):
DATADIR
=
dirname
(
__file__
)
+
sep
+
'test_data'
if
not
isdir
(
DATADIR
):
DATADIR
=
dirname
(
dirname
(
__file__
))
+
sep
+
'test_data'
self
.
test_target_file
=
DATADIR
+
sep
+
'test.xml'
def
test_init
(
self
):
wp
=
WritingProcess
()
self
.
assertEqual
(
wp
.
version
,
0
)
self
.
assertEqual
(
wp
.
description
,
WritingProcess
.
VERSION_DESCRIPTION
[
0
])
def
test_attachable
(
self
):
empty_tree
=
ET
.
ElementTree
(
ET
.
Element
(
'page'
))
wp
=
WritingProcess
()
wp
.
attach_object_to_tree
(
empty_tree
)
wp_node
=
empty_tree
.
xpath
(
'//'
+
WritingProcess
.
XML_TAG
)
self
.
assertEqual
(
len
(
wp_node
),
1
)
self
.
assertEqual
(
wp_node
[
0
]
.
get
(
'version'
),
str
(
wp
.
version
))
def
test_create_writing_process_from_xml
(
self
):
empty_tree
=
ET
.
ElementTree
(
ET
.
Element
(
'page'
))
wp
=
WritingProcess
()
wp
.
attach_object_to_tree
(
empty_tree
)
wp_node
=
empty_tree
.
xpath
(
'//'
+
WritingProcess
.
XML_TAG
)
wp2
=
WritingProcess
.
create_writing_process_from_xml
(
wp_node
[
0
])
self
.
assertEqual
(
wp2
.
version
,
wp
.
version
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Event Timeline
Log In to Comment