Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91234349
test_style.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, 05:35
Size
3 KB
Mime Type
text/x-python
Expires
Mon, Nov 11, 05:35 (2 d)
Engine
blob
Format
Raw Data
Handle
22226233
Attached To
rNIETZSCHEPYTHON nietzsche-python
test_style.py
View Options
import
unittest
from
os
import
sep
,
path
from
os.path
import
dirname
,
basename
,
isfile
,
isdir
import
lxml.etree
as
ET
import
sys
sys
.
path
.
append
(
'svgscripts'
)
from
datatypes.color
import
Color
from
datatypes.archival_manuscript
import
ArchivalManuscriptUnity
from
datatypes.page
import
Page
from
datatypes.style
import
Style
class
TestStyle
(
unittest
.
TestCase
):
def
setUp
(
self
):
DATADIR
=
dirname
(
__file__
)
+
sep
+
'test_data'
if
not
isdir
(
DATADIR
):
DATADIR
=
dirname
(
dirname
(
__file__
))
+
sep
+
'test_data'
self
.
test_file
=
DATADIR
+
sep
+
'test.xml'
self
.
test_svg_file
=
DATADIR
+
sep
+
'test421.svg'
self
.
pdf_xml
=
DATADIR
+
sep
+
'W_I_8_page125.xml'
self
.
xml_file
=
DATADIR
+
sep
+
'N_VII_1_page005.xml'
self
.
xml_fileB
=
DATADIR
+
sep
+
'N_VII_1_page006.xml'
self
.
pdf_xml_source
=
DATADIR
+
sep
+
'W_I_8_neu_125-01.svg'
self
.
test_page
=
DATADIR
+
sep
+
'N_VII_1_page001.xml'
self
.
test_manuscript
=
DATADIR
+
sep
+
'N_VII_1.xml'
self
.
test_styles_color
=
DATADIR
+
sep
+
'N_VII_1_page013.xml'
def
test_create_cls
(
self
):
page
=
Page
(
self
.
test_page
)
style_string
=
"st11 st10 st5"
style
=
Style
.
create_cls
(
page
,
style_string
)
self
.
assertEqual
(
style
.
font_family
,
'Weidemann-Book'
)
self
.
assertEqual
(
style
.
color
.
hex_color
,
"#DADADA"
)
self
.
assertEqual
(
style
.
writing_instrument
,
'schwarze Tinte'
)
style_string
=
"st11 st10"
style
=
Style
.
create_cls
(
page
,
style_string
)
self
.
assertEqual
(
style
.
font_family
,
'Weidemann-Book'
)
self
.
assertEqual
(
style
.
color
.
name
,
"black"
)
self
.
assertEqual
(
style
.
writing_instrument
,
'schwarze Tinte'
)
style_string
=
"st11 st3"
style
=
Style
.
create_cls
(
page
,
style_string
,
create_css
=
True
)
#style.writing_process_id = 1
#style.create_css_styles()
self
.
assertEqual
(
style
.
font_family
,
'Weidemann-Book'
)
self
.
assertEqual
(
style
.
font_size
,
'9px'
)
def
test_remove_irrelevant_style_keys
(
self
):
page
=
Page
(
self
.
test_page
)
style_string
=
"st11 st10 st9 st5 st0"
self
.
assertEqual
(
Style
.
remove_irrelevant_style_keys
(
style_string
,
page
),
"st11 st5 st9"
)
def
test_process_style_classes
(
self
):
style
=
Style
()
style
.
color
=
Color
.
create_cls
(
hex_color
=
'#009CDE'
)
style
.
process_style_classes
()
self
.
assertEqual
(
style
.
writing_instrument
,
'violette Tinte'
)
self
.
assertEqual
(
style
.
font
,
'deutsche Schreibschrift'
)
style
.
font_family
=
"NewsGothicBT-Bold"
style
.
process_style_classes
()
self
.
assertEqual
(
style
.
writing_instrument
,
'Blaustift'
)
self
.
assertEqual
(
style
.
font
,
'lateinische Schreibschrift'
)
style
=
Style
()
style
.
font_family
=
"NewsGothicBT-Bold"
style
.
process_style_classes
()
#print(style.css_styles)
def
test_get_semantic_dictionary
(
self
):
dictionary
=
Style
.
get_semantic_dictionary
()
#print(dictionary)
def
test_copy
(
self
):
manuscript
=
ArchivalManuscriptUnity
.
create_cls
(
self
.
test_manuscript
)
page
=
Page
(
self
.
test_page
)
page
.
words
=
[
page
.
words
[
0
]
]
page
.
update_styles
(
manuscript
=
manuscript
,
add_to_parents
=
True
)
self
.
assertEqual
(
len
(
manuscript
.
styles
),
1
)
styleA
=
page
.
words
[
0
]
.
transkription_positions
[
0
]
.
style
styleB
=
styleA
.
create_a_copy
()
self
.
assertEqual
(
styleA
==
styleB
,
True
)
styleB
=
styleA
.
create_a_copy
(
reduce_writing_process_id
=
True
)
self
.
assertEqual
(
styleA
!=
styleB
,
True
)
def
test_eq
(
self
):
page
=
Page
(
self
.
test_page
)
style_string
=
"st11 st10 st5"
styleA
=
Style
.
create_cls
(
page
,
style_string
)
styleB
=
Style
.
create_cls
(
page
,
style_string
)
self
.
assertEqual
(
styleA
==
styleB
,
True
)
style_string
=
"st11 st10"
styleC
=
Style
.
create_cls
(
page
,
style_string
)
self
.
assertEqual
(
styleA
!=
styleC
,
True
)
if
__name__
==
"__main__"
:
unittest
.
main
()
Event Timeline
Log In to Comment