Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61711749
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
Wed, May 8, 12:07
Size
1 KB
Mime Type
text/x-python
Expires
Fri, May 10, 12:07 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17548321
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_process_files.py
View Options
import
unittest
from
os
import
sep
,
path
,
remove
from
os.path
import
isfile
import
lxml.etree
as
ET
import
warnings
import
sys
sys
.
path
.
append
(
'svgscripts'
)
import
process_files
from
process_files
import
MyCSVHandler
,
MyErrorHandler
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
)
#self.assertEqual(csv_handler.process_files('asdf', 'asdf'), 0)
#print(csv_handler.csv_entries)
def
test_is_page_ok
(
self
):
self
.
assertEqual
(
process_files
.
is_page_ok
(
manuscript_file
=
self
.
manuscript
,
page_number
=
2
),
True
)
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