Esempio n. 1
0
 def test_plot_area(self):
     """
     Test the get_available_width() and get_available_height() functions.
     They should return the material width and height minus the padding
     around the outside.
     """
     plot = Plot(90 * 12, 90 * 12 * 4)
     plot.set_padding(35, 0, 35, 0)  # should be default but to make sure
     assert plot.get_available_width() == 90 * 12
     assert plot.get_available_height() == 90 * 12 * 4 - 70
Esempio n. 2
0
 def test_plot_area(self):
     """
     Test the get_available_width() and get_available_height() functions.
     They should return the material width and height minus the padding
     around the outside.
     """
     plot = Plot(90*12,90*12*4)
     plot.set_padding(35,0,35,0) # should be default but to make sure
     assert plot.get_available_width() == 90*12
     assert plot.get_available_height() == 90*12*4-70
Esempio n. 3
0
 def test_material_size_limited(self):
     """Test that the material is sized correctly when limited=True"""
     plot = Plot(90*12,90*12*4)
     plot.set_graphic(etree.parse("arrow.svg"))
     plot.set_padding(35,0,35,0)
     h = 170.563
     log.debug(" %s should = %s" %(round(plot.get_material_height(limited=True),3),h+70))
     assert round(plot.get_material_height(limited=True),3) == h+70
     w = 333.469
     log.debug(" %s should = %s" %(round(plot.get_material_width(limited=True),3),w))
     assert round(plot.get_material_width(limited=True),3) == w
Esempio n. 4
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)
Esempio n. 5
0
 def test_material_size_limited(self):
     """Test that the material is sized correctly when limited=True"""
     plot = Plot(90 * 12, 90 * 12 * 4)
     plot.set_graphic(etree.parse("arrow.svg"))
     plot.set_padding(35, 0, 35, 0)
     h = 170.563
     log.debug(" %s should = %s" %
               (round(plot.get_material_height(limited=True), 3), h + 70))
     assert round(plot.get_material_height(limited=True), 3) == h + 70
     w = 333.469
     log.debug(" %s should = %s" %
               (round(plot.get_material_width(limited=True), 3), w))
     assert round(plot.get_material_width(limited=True), 3) == w
Esempio n. 6
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)
Esempio n. 7
0
 def test_set_padding(self):
     """ Test the set_padding() """
     plot = Plot(90*12,90*12*4)
     plot.set_padding(35,0,35,0)
     assert plot.get_available_width() == 90*12
     assert plot.get_available_height() == 90*12*4-70
     plot.set_padding(top=30)
     assert plot.get_available_width() == 90*12
     assert plot.get_available_height() == 90*12*4-65
     plot.set_padding(right=30)
     assert plot.get_available_width() == 90*12-30
     assert plot.get_available_height() == 90*12*4-65
     plot.set_padding(left=17.3)
     assert plot.get_available_width() == 90*12-30-17.3
     assert plot.get_available_height() == 90*12*4-65
     plot.set_padding(bottom=0)
     assert plot.get_available_width() == 90*12-30-17.3
     assert plot.get_available_height() == 90*12*4-30
     plot.set_padding(top=35,right=0,bottom=35,left=0)
     assert plot.get_available_width() == 90*12
     assert plot.get_available_height() == 90*12*4-70
     plot.set_padding(top=0,right=0,bottom=0,left=0)
     assert plot.get_available_width() == 90*12
     assert plot.get_available_height() == 90*12*4
Esempio n. 8
0
 def test_set_padding(self):
     """ Test the set_padding() """
     plot = Plot(90 * 12, 90 * 12 * 4)
     plot.set_padding(35, 0, 35, 0)
     assert plot.get_available_width() == 90 * 12
     assert plot.get_available_height() == 90 * 12 * 4 - 70
     plot.set_padding(top=30)
     assert plot.get_available_width() == 90 * 12
     assert plot.get_available_height() == 90 * 12 * 4 - 65
     plot.set_padding(right=30)
     assert plot.get_available_width() == 90 * 12 - 30
     assert plot.get_available_height() == 90 * 12 * 4 - 65
     plot.set_padding(left=17.3)
     assert plot.get_available_width() == 90 * 12 - 30 - 17.3
     assert plot.get_available_height() == 90 * 12 * 4 - 65
     plot.set_padding(bottom=0)
     assert plot.get_available_width() == 90 * 12 - 30 - 17.3
     assert plot.get_available_height() == 90 * 12 * 4 - 30
     plot.set_padding(top=35, right=0, bottom=35, left=0)
     assert plot.get_available_width() == 90 * 12
     assert plot.get_available_height() == 90 * 12 * 4 - 70
     plot.set_padding(top=0, right=0, bottom=0, left=0)
     assert plot.get_available_width() == 90 * 12
     assert plot.get_available_height() == 90 * 12 * 4