예제 #1
0
파일: test_plot.py 프로젝트: xnoob/Inkcut
 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
예제 #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
예제 #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
예제 #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)
예제 #5
0
파일: test_plot.py 프로젝트: xnoob/Inkcut
 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
예제 #6
0
파일: test_plot.py 프로젝트: xnoob/Inkcut
 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)
예제 #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
예제 #8
0
파일: test_plot.py 프로젝트: xnoob/Inkcut
 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