def test_scale_y(self): """Check that graphic is scaled properly.""" graphic = Graphic(etree.parse("arrow.svg").getroot()) graphic.set_scale(3, 1) e = 1 w = 333.469 * 3 h = 170.563 assert w - e < graphic.get_width() < w + e, "Graphic width is wrong after scaling!" assert h - e < graphic.get_height() < h + e, "Graphic height is wrong after scaling!"
def test_scale_3(self): """Check that graphic is scaled properly.""" graphic = Graphic(etree.parse("arrow.svg").getroot()) graphic.set_scale(2.72) e = 1 w = 333.469 * 2.72 assert w - e < graphic.get_width() < w + e, "Graphic width is wrong after scaling!" graphic.set_scale(1) w = 333.469 assert w - e < graphic.get_width() < w + e, "Graphic width is wrong after scaling the second time!"
def test_case_5(self): """Check that graphic is scaled properly in the y direction.""" graphic = Graphic(etree.parse("arrow.svg").getroot()) graphic.set_scale(2) e = 1 h = 170.563 * 2 assert h - e < graphic.get_height() < h + e, "Graphic height is wrong after scaling!" graphic.set_scale(1) h = 170.563 assert h - e < graphic.get_height() < h + e, "Graphic height is wrong after scaling the second time!"
def test_scale_y(self): """Check that graphic is scaled properly.""" graphic = Graphic(etree.parse("arrow.svg").getroot()) graphic.set_scale(3, 1) e = 1 w = 333.469 * 3 h = 170.563 assert w - e < graphic.get_width( ) < w + e, "Graphic width is wrong after scaling!" assert h - e < graphic.get_height( ) < h + e, "Graphic height is wrong after scaling!"
def test_scale_3(self): """Check that graphic is scaled properly.""" graphic = Graphic(etree.parse("arrow.svg").getroot()) graphic.set_scale(2.72) e = 1 w = 333.469 * 2.72 assert w - e < graphic.get_width( ) < w + e, "Graphic width is wrong after scaling!" graphic.set_scale(1) w = 333.469 assert w - e < graphic.get_width( ) < w + e, "Graphic width is wrong after scaling the second time!"
def test_case_5(self): """Check that graphic is scaled properly in the y direction.""" graphic = Graphic(etree.parse("arrow.svg").getroot()) graphic.set_scale(2) e = 1 h = 170.563 * 2 assert h - e < graphic.get_height( ) < h + e, "Graphic height is wrong after scaling!" graphic.set_scale(1) h = 170.563 assert h - e < graphic.get_height( ) < h + e, "Graphic height is wrong after scaling the second time!"
def test_apply_cutting_overlap(self): """Test Plugin.apply_cutting_overlap()!""" overlap = 20 plugin = Plugin() g = Graphic("arrow.svg") g.set_scale(HPGL.HPGL_SCALE,HPGL.HPGL_SCALE) paths = g.get_polyline() lengths = [] for path in paths: lengths.append(g.get_path_length(path=path)) plugin.apply_cutting_overlap(paths,overlap) for path,length in zip(paths,lengths): if path_is_closed(path): new_length = g.get_path_length(path=path) assert round(length+overlap,10) == round(new_length,10), "%s != %s" % (round(length+overlap,10),round(new_length,10)) else: assert round(length,10) == round(new_length,10), "%s != %s" % (round(length,10),round(new_length,10))
def test_changed_flag(self): """Check that changed flag works correctly.""" graphic = Graphic(etree.parse("arrow.svg").getroot()) graphic.reset_changed_flag() graphic.set_mirror_x(True) assert graphic.get_changed_flag(), "Changed flag should be set!" graphic.reset_changed_flag() graphic.set_mirror_x(False) assert graphic.get_changed_flag(), "Changed flag should be set!" graphic.reset_changed_flag() graphic.set_scale(2) assert graphic.get_changed_flag(), "Changed flag should be set!" graphic.reset_changed_flag() graphic.set_rotation(2) assert graphic.get_changed_flag(), "Changed flag should be set!" graphic.reset_changed_flag() graphic.set_position(2, 500) assert not graphic.get_changed_flag(), "Changed flag should not be set!" graphic.reset_changed_flag() graphic.set_weedline(True) assert graphic.get_changed_flag(), "Changed flag should be set!"
def test_changed_flag(self): """Check that changed flag works correctly.""" graphic = Graphic(etree.parse("arrow.svg").getroot()) graphic.reset_changed_flag() graphic.set_mirror_x(True) assert graphic.get_changed_flag(), "Changed flag should be set!" graphic.reset_changed_flag() graphic.set_mirror_x(False) assert graphic.get_changed_flag(), "Changed flag should be set!" graphic.reset_changed_flag() graphic.set_scale(2) assert graphic.get_changed_flag(), "Changed flag should be set!" graphic.reset_changed_flag() graphic.set_rotation(2) assert graphic.get_changed_flag(), "Changed flag should be set!" graphic.reset_changed_flag() graphic.set_position(2, 500) assert not graphic.get_changed_flag( ), "Changed flag should not be set!" graphic.reset_changed_flag() graphic.set_weedline(True) assert graphic.get_changed_flag(), "Changed flag should be set!"
def test_apply_cutting_overlap(self): """Test Plugin.apply_cutting_overlap()!""" overlap = 20 plugin = Plugin() g = Graphic("arrow.svg") g.set_scale(HPGL.HPGL_SCALE, HPGL.HPGL_SCALE) paths = g.get_polyline() lengths = [] for path in paths: lengths.append(g.get_path_length(path=path)) plugin.apply_cutting_overlap(paths, overlap) for path, length in zip(paths, lengths): if path_is_closed(path): new_length = g.get_path_length(path=path) assert round(length + overlap, 10) == round(new_length, 10), "%s != %s" % (round( length + overlap, 10), round(new_length, 10)) else: assert round(length, 10) == round(new_length, 10), "%s != %s" % (round( length, 10), round(new_length, 10))