Draft: add Draft Layer unit tests

Also create a test `Layer` in the `draft_test_objects` script.
This commit is contained in:
vocx-fc
2020-07-03 09:47:34 -05:00
committed by Yorik van Havre
parent ee11678a58
commit 0fa3f8b81b
2 changed files with 47 additions and 0 deletions

View File

@@ -574,6 +574,40 @@ def _create_objects(doc=None,
t_xpos = 17000
t_ypos = 2200
_set_text(["Mirror"], Vector(t_xpos, t_ypos, 0))
_msg(16 * "-")
_msg("Layer")
layer = Draft.make_layer("Custom layer",
line_color=(0.33, 0.0, 0.49),
shape_color=(0.56, 0.89, 0.56),
line_width=4,
transparency=50)
cube = doc.addObject('Part::Box')
cube.Length = 350
cube.Width = 300
cube.Height = 250
cube.Placement.Base = Vector(14000, 5500, 0)
cone = doc.addObject('Part::Cone')
cone.Radius1 = 400
cone.Height = 600
cone.Angle = 270
cone.Placement.Base = Vector(15000, 6000, 0)
sphere = doc.addObject('Part::Sphere')
sphere.Radius = 450
sphere.Angle1 = -45
sphere.Angle2 = 45
sphere.Angle3 = 300
sphere.Placement.Base = Vector(14000, 7000, 0)
layer.Proxy.addObject(layer, cube)
layer.Proxy.addObject(layer, cone)
layer.Proxy.addObject(layer, sphere)
t_xpos = 14000
t_ypos = 5000
_set_text(["Layer"], Vector(t_xpos, t_ypos, 0))
doc.recompute()

View File

@@ -348,6 +348,19 @@ class DraftCreation(unittest.TestCase):
self.doc.recompute()
self.assertTrue(obj, "'{}' failed".format(operation))
def test_layer(self):
"""Create a layer, and add a rectangle to it."""
operation = "Draft Layer"
_msg(" Test '{}'".format(operation))
length = 5
width = 2
_msg(" length={0}, width={1}".format(length, width))
rect = Draft.make_rectangle(length, width)
obj = Draft.make_layer()
obj.Proxy.addObject(obj, rect)
self.assertTrue(obj, "'{}' failed".format(operation))
def tearDown(self):
"""Finish the test.