def test_color(self): style = Style() assert style.color() == Style.DEFAULT_STYLE["color"] style.add_color((0.1, 0.2, 0.3)) assert style.color() == [(0.1, 0.2, 0.3)] style = Style() style.add_color((0.1, 0.2, 0.3, 0.4)) assert style.color() == [(0.1, 0.2, 0.3, 0.4)] assert_raises(ValueError, style.add_color, (0.1, 0.2))
def test_color(self): style = Style() assert style.color() == Style.DEFAULT_STYLE['color'] style.add_color((0.1, 0.2, 0.3)) assert style.color() == [(0.1, 0.2, 0.3)] style = Style() style.add_color((0.1, 0.2, 0.3, 0.4)) assert style.color() == [(0.1, 0.2, 0.3, 0.4)] assert_raises(ValueError, style.add_color, (0.1, 0.2))
def test_merge(self): style1 = Style(option_list=["red", "no-shadow", 3]) style2 = Style(option_list=["blue", "dotted"]) style1.merge(style2) assert style1.color() == [Style.COLORS["blue"]] assert style1.fill_type() == "dotted" assert style1.shadow() == "off" assert style1.width() == 3
def test_merge(self): style1 = Style(option_list=['red', 'no-shadow', 3]) style2 = Style(option_list=['blue', 'dotted']) style1.merge(style2) assert style1.color() == [Style.COLORS['blue']] assert style1.fill_type() == 'dotted' assert style1.shadow() == 'off' assert style1.width() == 3
def test_run(self): parser = StyleParser() arrow_style = Style('_arrow_', 'fill', ['red'], 1) fill_style = Style('.*', 'fill', ['blue'], 0) line_style = Style('_line_', 'fill', ['green'], 2) frame_style = Style('.*', 'frame', [[0.1, 0.2, 0.3]], 0) custom_fill_style = Style('(abc)|(def)', 'fill', [[0.3, 0.2, 0.3]], 3) custom_line_style = Style('line', 'fill', [[0.4, 0.3, 0.3]], 3) custom_frame_style = Style('(abc)|(def)', 'frame', [[0.5, 0.2, 0.3]], 3) polygon1 = Polygon([Node(0, 0)]) opengraph1 = OpenGraph() opengraph2 = OpenGraph() opengraph2.add_name('line') arrow = Arrow() background = Background() polygon2 = Polygon([Node(0, 0)]) polygon2.add_name('abc') polygon3 = Polygon([Node(0, 0)]) polygon3.add_name('def') objects = [arrow_style, fill_style, line_style, frame_style, custom_fill_style, custom_line_style, custom_frame_style, polygon1, polygon2, polygon3, opengraph1, opengraph2, arrow, background] parser.run([], objects) assert arrow.style().color() == arrow_style.color(), str(arrow.style().color()) + " != " + str(arrow_style.color()) assert polygon1.style().color() == fill_style.color(), str(polygon1.style().color()) + " != " + str(fill_style.color()) assert polygon1.frame().style().color() == frame_style.color() assert opengraph1.style().color() == line_style.color() assert opengraph2.style().color() == custom_line_style.color() assert polygon2.style().color() == custom_fill_style.color() assert polygon3.style().color() == custom_fill_style.color() assert polygon2.frame().style().color() == custom_frame_style.color() assert polygon3.frame().style().color() == custom_frame_style.color()
def test_run(self): parser = StyleParser() arrow_style = Style('_arrow_', 'fill', ['red'], 1) fill_style = Style('.*', 'fill', ['blue'], 0) line_style = Style('_line_', 'fill', ['green'], 2) frame_style = Style('.*', 'frame', [[0.1, 0.2, 0.3]], 0) custom_fill_style = Style('(abc)|(def)', 'fill', [[0.3, 0.2, 0.3]], 3) custom_line_style = Style('line', 'fill', [[0.4, 0.3, 0.3]], 3) custom_frame_style = Style('(abc)|(def)', 'frame', [[0.5, 0.2, 0.3]], 3) polygon1 = Polygon([Node(0, 0)]) opengraph1 = OpenGraph() opengraph2 = OpenGraph() opengraph2.add_name('line') arrow = Arrow() background = Background() polygon2 = Polygon([Node(0, 0)]) polygon2.add_name('abc') polygon3 = Polygon([Node(0, 0)]) polygon3.add_name('def') objects = [ arrow_style, fill_style, line_style, frame_style, custom_fill_style, custom_line_style, custom_frame_style, polygon1, polygon2, polygon3, opengraph1, opengraph2, arrow, background ] parser.run([], objects) assert arrow.style().color() == arrow_style.color(), str( arrow.style().color()) + " != " + str(arrow_style.color()) assert polygon1.style().color() == fill_style.color(), str( polygon1.style().color()) + " != " + str(fill_style.color()) assert polygon1.frame().style().color() == frame_style.color() assert opengraph1.style().color() == line_style.color() assert opengraph2.style().color() == custom_line_style.color() assert polygon2.style().color() == custom_fill_style.color() assert polygon3.style().color() == custom_fill_style.color() assert polygon2.frame().style().color() == custom_frame_style.color() assert polygon3.frame().style().color() == custom_frame_style.color()
def test_init(self): style = Style() assert style != None style = Style(option_list=["red", "no-shadow", 3]) assert style.color() == [Style.COLORS["red"]] assert style.shadow() == "off" assert style.width() == 3 style = Style(option_list=["shadow", 3.2]) assert style.shadow() == "on" assert style.width() == 3.2 style = Style(option_list=["solid"]) assert style.fill_type() == "solid" style = Style(option_list=["dashed"]) assert style.fill_type() == "dashed" style = Style(option_list=["dash-dotted"]) assert style.fill_type() == "dash-dotted" style = Style(option_list=["dotted"]) assert style.fill_type() == "dotted"
def test_init(self): style = Style() assert style != None style = Style(option_list=['red', 'no-shadow', 3]) assert style.color() == [Style.COLORS['red']] assert style.shadow() == 'off' assert style.width() == 3 style = Style(option_list=['shadow', 3.2]) assert style.shadow() == 'on' assert style.width() == 3.2 style = Style(option_list=['solid']) assert style.fill_type() == 'solid' style = Style(option_list=['dashed']) assert style.fill_type() == 'dashed' style = Style(option_list=['dash-dotted']) assert style.fill_type() == 'dash-dotted' style = Style(option_list=['dotted']) assert style.fill_type() == 'dotted'