Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_add_cell_styles_will_add_lineafter_style_if_borderright_attrs_set_on_context_frag(self):
context = pisaContext([])
context.frag.borderRightStyle = "solid"
context.frag.borderRightWidth = "3px"
context.frag.borderRightColor = "black"
instance = self.sut()
instance.add_cell_styles(context, (0, 1), (3, 5), mode="tr")
self.assertEqual(instance.styles[0], ('LINEAFTER', (3, 1), (3, 5), '3px', 'black', 'squared'))
def test_add_cell_styles_will_add_linebelow_style_if_borderbottom_attrs_set_on_context_frag(self):
context = pisaContext([])
context.frag.borderBottomStyle = "solid"
context.frag.borderBottomWidth = "3px"
context.frag.borderBottomColor = "black"
instance = self.sut()
instance.add_cell_styles(context, (0, 1), (3, 5), mode="tr")
self.assertEqual(instance.styles[0], ('LINEBELOW', (0, 5), (3, 5), '3px', 'black', 'squared'))
def test_add_cell_styles_will_not_add_lineafter_style_if_borderright_width_set_to_zero_on_context_frag(self):
context = pisaContext([])
context.frag.borderRightStyle = "solid"
context.frag.borderRightWidth = 0
context.frag.borderRightColor = "black"
instance = self.sut()
instance.add_cell_styles(context, (0, 1), (3, 5), mode="tr")
self.assertNotEqual(instance.styles[0][0], 'LINEAFTER')
def test_add_cell_styles_will_not_add_linebelow_style_if_borderbottom_color_not_set_on_context_frag(self):
context = pisaContext([])
context.frag.borderBottomStyle = "solid"
context.frag.borderBottomWidth = "3px"
instance = self.sut()
instance.add_cell_styles(context, (0, 1), (3, 5), mode="tr")
self.assertNotEqual(instance.styles[0][0], 'LINEBELOW')
def test_add_cell_styles_will_add_padding_styles_based_on_frag_padding_attrs(self):
context = pisaContext([])
context.frag.paddingRight = 5
instance = self.sut()
instance.add_cell_styles(context, (0, 1), (3, 5), mode="td")
self.assertEqual(instance.styles[0], ('LEFTPADDING', (0, 1), (3, 5), 0))
self.assertEqual(instance.styles[1], ('RIGHTPADDING', (0, 1), (3, 5), 5))
self.assertEqual(instance.styles[2], ('TOPPADDING', (0, 1), (3, 5), 0))
self.assertEqual(instance.styles[3], ('BOTTOMPADDING', (0, 1), (3, 5), 0))
def test_add_cell_styles_will_not_add_linebefore_style_if_borderleft_width_set_to_zero_on_context_frag(self):
context = pisaContext([])
context.frag.borderLeftStyle = "solid"
context.frag.borderLeftWidth = 0
context.frag.borderLeftColor = "black"
instance = self.sut()
instance.add_cell_styles(context, (0, 1), (3, 5), mode="tr")
self.assertNotEqual(instance.styles[0][0], 'LINEBEFORE')
def test_td_tag_doesnt_collapse_when_empty(self):
dom = minidom.parseString("")
element = dom.getElementsByTagName("td")[0]
attrs = AttrContainer({
'align': None,
'colspan': None,
'rowspan': None,
'width': None,
'valign': None,
})
context = pisaContext([])
table_data = tables.TableData()
table_data.col = 0
table_data.row = 0
table_data.colw = []
table_data.rowh = []
context.tableData = table_data
context.frag.paddingLeft = 0
context.frag.paddingRight = 0
instance = tables.pisaTagTD(element, attrs)
instance.start(context)
self.assertEqual(context.tableData.colw, [None])
def test_add_cell_styles_will_not_add_linebelow_style_if_borderbottom_width_set_to_zero_on_context_frag(self):
context = pisaContext([])
context.frag.borderBottomStyle = "solid"
context.frag.borderBottomWidth = 0
context.frag.borderBottomColor = "black"
instance = self.sut()
instance.add_cell_styles(context, (0, 1), (3, 5), mode="tr")
self.assertNotEqual(instance.styles[0][0], 'LINEBELOW')
def test_add_cell_styles_will_not_add_lineabove_style_if_bordertop_style_not_set_on_context_frag(self):
context = pisaContext([])
context.frag.borderTopWidth = "3px"
context.frag.borderTopColor = "black"
instance = self.sut()
instance.add_cell_styles(context, (0, 1), (3, 5), mode="tr")
self.assertNotEqual(instance.styles[0][0], 'LINEABOVE')
def pisaStory(src, path=None, link_callback=None, debug=0, default_css=None,
xhtml=False, encoding=None, context=None, xml_output=None,
**kw):
# Prepare Context
if not context:
context = pisaContext(path, debug=debug)
context.pathCallback = link_callback
# Use a default set of CSS definitions to get an expected output
if default_css is None:
default_css = DEFAULT_CSS
# Parse and fill the story
pisaParser(src, context, default_css, xhtml, encoding, xml_output)
# Avoid empty documents
if not context.story:
context.story = [Spacer(1, 1)]
if context.indexing_story:
context.story.append(context.indexing_story)