Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61351559
test_process_files.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
Mon, May 6, 03:25
Size
2 KB
Mime Type
text/x-python
Expires
Wed, May 8, 03:25 (2 d)
Engine
blob
Format
Raw Data
Handle
17499545
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_process_files.py
View Options
import
unittest
from
os
import
sep
,
path
,
remove
from
os.path
import
isfile
,
dirname
import
lxml.etree
as
ET
import
warnings
import
sys
sys
.
path
.
append
(
'svgscripts'
)
import
process_files
from
process_files
import
MyCSVHandler
,
MyErrorHandler
from
datatypes.page_creator
import
PageCreator
class
TestProcessFiles
(
unittest
.
TestCase
):
def
setUp
(
self
):
process_files
.
UNITTESTING
=
True
DATADIR
=
path
.
dirname
(
__file__
)
+
sep
+
'test_data'
self
.
csv_file
=
DATADIR
+
sep
+
'bd_12_Layout.csv'
self
.
dir
=
DATADIR
+
sep
+
'pdfsvg'
self
.
csv_dir
=
self
.
dir
+
sep
+
'csv'
self
.
manuscript
=
self
.
dir
+
sep
+
'W_II_1.xml'
self
.
graphic_file
=
self
.
dir
+
sep
+
'W_II_1_page001_web.svg'
self
.
multipdf
=
DATADIR
+
sep
+
'Bd_12_Mp_XIV_-XVI_Druck.pdf'
@unittest.skipUnless
(
__name__
==
"__main__"
,
'test takes too long, we do not run it with unittest discover'
)
def
test_main
(
self
):
#self.assertEqual(process_files.main([ self.manuscript ]), 1)
argv
=
[
'-g'
,
'-x'
,
self
.
dir
,
'-s'
,
self
.
dir
,
self
.
dir
]
self
.
assertEqual
(
process_files
.
main
(
argv
),
0
)
self
.
assertEqual
(
isfile
(
self
.
graphic_file
),
True
)
def
test_csvhandler
(
self
):
csv_handler
=
MyCSVHandler
(
self
.
csv_file
,
self
.
multipdf
,
self
.
csv_dir
)
self
.
assertEqual
(
len
([
entry
for
entry
in
csv_handler
.
csv_entries
if
entry
[
MyCSVHandler
.
ENTRY_KEY_FILE
]
is
not
None
]),
9
)
csv_handler
=
MyCSVHandler
(
self
.
csv_file
,
self
.
multipdf
,
self
.
csv_dir
,
title
=
"Mp XV"
)
self
.
assertEqual
(
len
([
entry
for
entry
in
csv_handler
.
csv_entries
if
entry
[
MyCSVHandler
.
ENTRY_KEY_FILE
]
is
not
None
]),
2
)
#print(csv_handler.csv_entries)
#self.assertEqual(csv_handler.process_files('asdf', 'asdf'), 0)
def
test_page_status
(
self
):
self
.
assertEqual
(
process_files
.
is_page_ok
(
manuscript_file
=
self
.
manuscript
,
page_number
=
2
),
True
)
#self.assertEqual(process_files.page_has_status(process_files.WARN_MISSING_USE_NODE, manuscript_file=self.manuscript, page_number='1'), True)
#self.assertEqual(process_files.get_page_output_file('2', manuscript_file=self.manuscript), dirname(self.manuscript) + sep + 'W_II_1_page001.xml')
def
test_is_svg_ok
(
self
):
self
.
assertEqual
(
process_files
.
is_svg_ok
(
manuscript_file
=
self
.
manuscript
,
page_number
=
1
),
True
)
@unittest.skip
(
''
)
def
test_run
(
self
):
error_handler
=
MyErrorHandler
()
error_handler
.
run
(
page_number
=
'15'
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Event Timeline
Log In to Comment