From 33650efbe8e4c97086775fc7a83a4cf909ffb075 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Sat, 24 Jul 2021 10:59:43 -0500 Subject: [PATCH 1/4] Path: Delete dead code and comments --- src/Mod/Path/PathTests/TestPathAdaptive.py | 85 ---------------------- 1 file changed, 85 deletions(-) diff --git a/src/Mod/Path/PathTests/TestPathAdaptive.py b/src/Mod/Path/PathTests/TestPathAdaptive.py index 56ccf52f88..96185ec192 100644 --- a/src/Mod/Path/PathTests/TestPathAdaptive.py +++ b/src/Mod/Path/PathTests/TestPathAdaptive.py @@ -46,10 +46,6 @@ class TestPathAdaptive(PathTestBase): ''' # Create a new document and create test geometry - # doc_title = "TestAdaptive" - # doc = FreeCAD.newDocument(doc_title) - # cls._createTestGeometry(doc) - # Open existing document with test geometry doc = FreeCAD.open(FreeCAD.getHomePath() + 'Mod/Path/PathTests/test_adaptive.fcstd') @@ -83,28 +79,6 @@ class TestPathAdaptive(PathTestBase): else: FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name) - @staticmethod - def _createTestGeometry(doc): - '''_createTestGeometry(doc)... - This contains the instructions to create test geometry for the unit tests in this class. - A simple example creation is provided. - ''' - - # Create a square donut - box0 = doc.addObject('Part::Box', 'Box0') # Box - box0.Length = 50.0 - box0.Width = 50.0 - box0.Height = 10.0 - box1 = doc.addObject('Part::Box', 'Box1') # Box001 - box1.Length = 10.0 # X - box1.Width = 10.0 # Y - box1.Height = 20.0 # Z - box1.Placement = FreeCAD.Placement(FreeCAD.Vector(10.0, 10.0, -5.0), FreeCAD.Rotation(FreeCAD.Vector(0,0,1), 0)) - cut0 = doc.addObject('Part::Cut', 'Cut0') - cut0.Base = box0 - cut0.Tool = box1 - doc.recompute() - # Setup and tear down methods called before and after each unit test def setUp(self): '''setUp()... @@ -461,7 +435,6 @@ def pathOriginatesInBox(cmd, minPoint, maxPoint): return False - def _addViewProvider(adaptiveOp): if FreeCAD.GuiUp: PathOpGui = PathAdaptiveGui.PathOpGui @@ -484,61 +457,3 @@ G1 X17.5 Y20.0 Z5.0; \ G1 X32.5 Y20.0 Z5.0; \ G1 X32.5 Y17.5 Z5.0; \ G1 X17.5 Y17.5 Z5.0" - -expected_moves_test02 = "G1 X22.5 Y-17.5 Z15.0; \ -G1 X22.5 Y-22.5 Z15.0; \ -G1 X17.5 Y-22.5 Z15.0; \ -G1 X17.5 Y-17.5 Z15.0; \ -G1 X22.5 Y-17.5 Z15.0; \ -G1 X21.25 Y-18.75 Z15.0; \ -G1 X21.25 Y-21.25 Z15.0; \ -G1 X18.75 Y-21.25 Z15.0; \ -G1 X18.75 Y-18.75 Z15.0; \ -G1 X21.25 Y-18.75 Z15.0" - -expected_moves_test03 = "G1 X32.5 Y-22.5 Z5.0; \ -G1 X32.5 Y-22.76 Z5.0; \ -G3 I2.4 J-12.0 K0.0 X27.5 Y-25.01 Z5.0; \ -G1 X27.5 Y-25.0 Z5.0; \ -G1 X27.5 Y-22.5 Z5.0; \ -G1 X32.5 Y-22.5 Z5.0; \ -G1 X25.02 Y-27.5 Z5.0; \ -G3 I9.66 J-7.36 K0.0 X22.76 Y-32.5 Z5.0; \ -G1 X22.5 Y-32.5 Z5.0; \ -G1 X22.5 Y-27.5 Z5.0; \ -G1 X25.0 Y-27.5 Z5.0; \ -G1 X25.02 Y-27.5 Z5.0" - -expected_moves_test04 = "G1 X25.0 Y-15.0 Z15.0; \ -G1 X15.0 Y-15.0 Z15.0; \ -G1 X15.0 Y-25.0 Z15.0; \ -G1 X25.0 Y-25.0 Z15.0; \ -G1 X25.0 Y-22.5 Z15.0; \ -G1 X22.5 Y-22.5 Z15.0; \ -G1 X22.5 Y-17.5 Z15.0; \ -G1 X17.5 Y-17.5 Z15.0; \ -G1 X17.5 Y-22.5 Z15.0; \ -G1 X22.5 Y-22.5 Z15.0; \ -G1 X25.0 Y-22.5 Z15.0; \ -G1 X25.0 Y-15.0 Z15.0" - -expected_moves_test05 = "G1 X32.5 Y32.5 Z5.0; \ -G1 X32.5 Y17.5 Z5.0; \ -G1 X17.5 Y17.5 Z5.0; \ -G1 X17.5 Y32.5 Z5.0; \ -G1 X32.5 Y32.5 Z5.0; \ -G1 X30.0 Y30.0 Z5.0; \ -G1 X30.0 Y20.0 Z5.0; \ -G1 X20.0 Y20.0 Z5.0; \ -G1 X20.0 Y30.0 Z5.0; \ -G1 X30.0 Y30.0 Z5.0; \ -G1 X27.5 Y27.5 Z5.0; \ -G1 X27.5 Y22.5 Z5.0; \ -G1 X22.5 Y22.5 Z5.0; \ -G1 X22.5 Y27.5 Z5.0; \ -G1 X27.5 Y27.5 Z5.0; \ -G1 X26.25 Y26.25 Z5.0; \ -G1 X26.25 Y23.75 Z5.0; \ -G1 X23.75 Y23.75 Z5.0; \ -G1 X23.75 Y26.25 Z5.0; \ -G1 X26.25 Y26.25 Z5.0" \ No newline at end of file From 6b822558e631e907b81850a47a8d4ef62d3bafab Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Sat, 24 Jul 2021 11:00:17 -0500 Subject: [PATCH 2/4] Path: Improve comments and docStrings --- src/Mod/Path/PathTests/TestPathAdaptive.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Mod/Path/PathTests/TestPathAdaptive.py b/src/Mod/Path/PathTests/TestPathAdaptive.py index 96185ec192..5c95b581f7 100644 --- a/src/Mod/Path/PathTests/TestPathAdaptive.py +++ b/src/Mod/Path/PathTests/TestPathAdaptive.py @@ -2,6 +2,8 @@ # *************************************************************************** # * Copyright (c) 2021 Russell Johnson (russ4262) * # * * +# * This file is part of the FreeCAD CAx development system. * +# * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU Lesser General Public License (LGPL) * # * as published by the Free Software Foundation; either version 2 of * @@ -45,8 +47,7 @@ class TestPathAdaptive(PathTestBase): is able to call static methods within this same class. ''' - # Create a new document and create test geometry - # Open existing document with test geometry + # Open existing FreeCAD document with test geometry doc = FreeCAD.open(FreeCAD.getHomePath() + 'Mod/Path/PathTests/test_adaptive.fcstd') # Create Job object, adding geometry objects from file opened above @@ -97,7 +98,7 @@ class TestPathAdaptive(PathTestBase): # Unit tests def test00(self): - '''test00() Empty test: Verify default property values.''' + '''test00() Empty test.''' return def test01(self): @@ -343,6 +344,7 @@ def setDepthsAndHeights(op, strDep=20.0, finDep=0.0): # Set Heights # default values used + def getGcodeMoves(cmdList, includeRapids=True, includeLines=True, includeArcs=True): '''getGcodeMoves(cmdList, includeRapids=True, includeLines=True, includeArcs=True)... Accepts command dict and returns point string coordinate. @@ -442,7 +444,8 @@ def _addViewProvider(adaptiveOp): adaptiveOp.ViewObject.Proxy = PathOpGui.ViewProvider(adaptiveOp.ViewObject, cmdRes) -# Expected moves for unit tests +# Example string literal of expected path moves from an operation +# Expected moves for unit test01 expected_moves_test01 = "G1 X32.5 Y32.5 Z5.0; \ G1 X17.5 Y32.5 Z5.0; \ G1 X17.5 Y30.0 Z5.0; \ From 23b4c1363bc8bc904b73f370a6ec420b6cf336d4 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Sat, 24 Jul 2021 21:39:25 -0500 Subject: [PATCH 3/4] Path: Re-enable all disabled Path unit tests --- src/Mod/Path/TestPathApp.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Mod/Path/TestPathApp.py b/src/Mod/Path/TestPathApp.py index e436dbd86c..961046d948 100644 --- a/src/Mod/Path/TestPathApp.py +++ b/src/Mod/Path/TestPathApp.py @@ -24,7 +24,6 @@ import TestApp # from PathTests.TestPathPost import PathPostTestCases from PathTests.TestPathAdaptive import TestPathAdaptive -""" from PathTests.TestPathCore import TestPathCore from PathTests.TestPathDeburr import TestPathDeburr from PathTests.TestPathDepthParams import depthTestCases @@ -46,17 +45,13 @@ from PathTests.TestPathTooltable import TestPathTooltable from PathTests.TestPathUtil import TestPathUtil from PathTests.TestPathVcarve import TestPathVcarve from PathTests.TestPathVoronoi import TestPathVoronoi -""" # dummy usage to get flake8 and lgtm quiet -""" False if depthTestCases.__name__ else True False if TestApp.__name__ else True False if TestDressupDogbone.__name__ else True False if TestHoldingTags.__name__ else True -""" False if TestPathAdaptive.__name__ else True -""" False if TestPathCore.__name__ else True False if TestPathDeburr.__name__ else True False if TestPathGeom.__name__ else True @@ -75,4 +70,3 @@ False if TestPathTooltable.__name__ else True False if TestPathUtil.__name__ else True False if TestPathVcarve.__name__ else True False if TestPathVoronoi.__name__ else True -""" From 249b3f5133950d343a75c96fb66662cd561998b4 Mon Sep 17 00:00:00 2001 From: Russell Johnson <47639332+Russ4262@users.noreply.github.com> Date: Sat, 24 Jul 2021 21:59:05 -0500 Subject: [PATCH 4/4] Path: Close Adaptive geometry source file upon unit test completion --- src/Mod/Path/PathTests/TestPathAdaptive.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Mod/Path/PathTests/TestPathAdaptive.py b/src/Mod/Path/PathTests/TestPathAdaptive.py index 5c95b581f7..8e053df53d 100644 --- a/src/Mod/Path/PathTests/TestPathAdaptive.py +++ b/src/Mod/Path/PathTests/TestPathAdaptive.py @@ -74,11 +74,8 @@ class TestPathAdaptive(PathTestBase): ''' # FreeCAD.Console.PrintMessage("TestPathAdaptive.tearDownClass()\n") - # Do not close document unless unit tests are commandline only - if FreeCAD.GuiUp: - pass - else: - FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name) + # Close geometry document without saving + FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name) # Setup and tear down methods called before and after each unit test def setUp(self):