def test_align_center_x(self): """ Makes sure the graphic is centered correctly in the x direction""" plot = Plot(90*12,90*12*4) plot.set_padding(35,0,35,0) plot.set_graphic(etree.tostring(etree.parse("arrow.svg"))) plot.set_align_center_x(True) f = open("out/plot_%s.svg"%sys._getframe().f_code.co_name,"w") f.write(plot.get_preview_xml()) f.close() log.debug("Checking position...") assert round(plot.get_position()[0],10) == round((90*12-plot.graphic.get_width())/2,10), "%s != %s" % (round(plot.get_position()[0],10),round((90*12-plot.graphic.get_width())/2,10)) assert round(plot.get_position()[1],10) == 0, "%s != %s" % (round(plot.get_position()[1],10),0)
def test_align_center_x(self): """ Makes sure the graphic is centered correctly in the x direction""" plot = Plot(90 * 12, 90 * 12 * 4) plot.set_padding(35, 0, 35, 0) plot.set_graphic(etree.tostring(etree.parse("arrow.svg"))) plot.set_align_center_x(True) f = open("out/plot_%s.svg" % sys._getframe().f_code.co_name, "w") f.write(plot.get_preview_xml()) f.close() log.debug("Checking position...") assert round(plot.get_position()[0], 10) == round( (90 * 12 - plot.graphic.get_width()) / 2, 10), "%s != %s" % (round( plot.get_position()[0], 10), round((90 * 12 - plot.graphic.get_width()) / 2, 10)) assert round( plot.get_position()[1], 10) == 0, "%s != %s" % (round(plot.get_position()[1], 10), 0)
def test_set_position(self): """ Test set_position()""" plot = Plot(90*12,90*12*4) plot.set_graphic(etree.tostring(etree.parse("arrow.svg"))) log.info("Checking position 0,0...") assert map(lambda x:round(x,10),plot.get_position()) == [0,0], "Got %s" % map(lambda x:round(x,10),plot.get_position()) log.info("OK") log.info("Checking position 50,0...") plot.set_position(50,0) assert map(lambda x:round(x,10),plot.get_position()) == [50,0], "Got %s" % map(lambda x:round(x,10),plot.get_position()) log.info("OK") log.info("Checking position 13.2,459...") plot.set_position(13.2,459) assert map(lambda x:round(x,10),plot.get_position()) == [13.2,459], "Got %s" % map(lambda x:round(x,10),plot.get_position()) log.info("OK") f = open("out/plot_%s_1.svg"%sys._getframe().f_code.co_name,"w") f.write(plot.get_preview_xml()) f.close()
def test_set_position(self): """ Test set_position()""" plot = Plot(90 * 12, 90 * 12 * 4) plot.set_graphic(etree.tostring(etree.parse("arrow.svg"))) log.info("Checking position 0,0...") assert map(lambda x: round(x, 10), plot.get_position()) == [ 0, 0 ], "Got %s" % map(lambda x: round(x, 10), plot.get_position()) log.info("OK") log.info("Checking position 50,0...") plot.set_position(50, 0) assert map(lambda x: round(x, 10), plot.get_position()) == [ 50, 0 ], "Got %s" % map(lambda x: round(x, 10), plot.get_position()) log.info("OK") log.info("Checking position 13.2,459...") plot.set_position(13.2, 459) assert map(lambda x: round(x, 10), plot.get_position()) == [ 13.2, 459 ], "Got %s" % map(lambda x: round(x, 10), plot.get_position()) log.info("OK") f = open("out/plot_%s_1.svg" % sys._getframe().f_code.co_name, "w") f.write(plot.get_preview_xml()) f.close()