From 3260a024035b3b8745d26b3821cc7206586b4798 Mon Sep 17 00:00:00 2001 From: Renaud NEDELEC Date: Wed, 14 Oct 2015 16:43:27 +0200 Subject: [PATCH] [PythonAPI] added tests in the standard way for Shaper --- src/PythonAPI/CMakeLists.txt | 8 ++++++ .../{modeler/tests => Test}/CMakeLists.txt | 0 .../TestModeler.py} | 0 src/PythonAPI/Test/TestSketcher.py | 26 +++++++++++++++++++ .../{modeler/tests => Test}/test_sketcher.py | 0 .../unit_test_experiment/CMakeLists.txt | 2 -- src/PythonAPI/unit_test_experiment/test.py | 8 ------ 7 files changed, 34 insertions(+), 10 deletions(-) rename src/PythonAPI/{modeler/tests => Test}/CMakeLists.txt (100%) rename src/PythonAPI/{modeler/tests/modeler_test_case.py => Test/TestModeler.py} (100%) create mode 100644 src/PythonAPI/Test/TestSketcher.py rename src/PythonAPI/{modeler/tests => Test}/test_sketcher.py (100%) delete mode 100644 src/PythonAPI/unit_test_experiment/CMakeLists.txt delete mode 100644 src/PythonAPI/unit_test_experiment/test.py diff --git a/src/PythonAPI/CMakeLists.txt b/src/PythonAPI/CMakeLists.txt index c89a79868..ac9909369 100644 --- a/src/PythonAPI/CMakeLists.txt +++ b/src/PythonAPI/CMakeLists.txt @@ -4,3 +4,11 @@ SET(CMAKE_AUTOMOC ON) INSTALL(DIRECTORY extension geom modeler DESTINATION pythonAPI) + +# --------- Unit tests ----------- +INCLUDE(UnitTest) + +ADD_UNIT_TESTS( + TestModeler.py + TestSketcher.py + ) diff --git a/src/PythonAPI/modeler/tests/CMakeLists.txt b/src/PythonAPI/Test/CMakeLists.txt similarity index 100% rename from src/PythonAPI/modeler/tests/CMakeLists.txt rename to src/PythonAPI/Test/CMakeLists.txt diff --git a/src/PythonAPI/modeler/tests/modeler_test_case.py b/src/PythonAPI/Test/TestModeler.py similarity index 100% rename from src/PythonAPI/modeler/tests/modeler_test_case.py rename to src/PythonAPI/Test/TestModeler.py diff --git a/src/PythonAPI/Test/TestSketcher.py b/src/PythonAPI/Test/TestSketcher.py new file mode 100644 index 000000000..ece5331de --- /dev/null +++ b/src/PythonAPI/Test/TestSketcher.py @@ -0,0 +1,26 @@ +import unittest +import modeler + +class SketcherTestCase(unittest.TestCase): + def setUp(self): + modeler.begin() + partset = modeler.moduleDocument() + part = modeler.addPart(partset).document() + plane = modeler.defaultPlane("XOY") + self.sketch = modeler.addSketch(part, plane) + + def tearDown(self): + modeler.end() + + def test_add_line(self): + print "add_line" + self.sketch.addLine(0, 0, 0, 1) + + def test_set_coincident(self): + print "set_coincident" + l1 = self.sketch.addLine(0, 0, 0, 1) + l2 = self.sketch.addLine(0, 1, 1, 1) + self.sketch.setCoincident(l1.endPointData(), l2.startPointData()) + +if __name__ == "__main__": + unittest.main() diff --git a/src/PythonAPI/modeler/tests/test_sketcher.py b/src/PythonAPI/Test/test_sketcher.py similarity index 100% rename from src/PythonAPI/modeler/tests/test_sketcher.py rename to src/PythonAPI/Test/test_sketcher.py diff --git a/src/PythonAPI/unit_test_experiment/CMakeLists.txt b/src/PythonAPI/unit_test_experiment/CMakeLists.txt deleted file mode 100644 index a90bdef98..000000000 --- a/src/PythonAPI/unit_test_experiment/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -enable_testing() -add_test(NAME "test" COMMAND "python" "test.py") diff --git a/src/PythonAPI/unit_test_experiment/test.py b/src/PythonAPI/unit_test_experiment/test.py deleted file mode 100644 index 9a5184a4a..000000000 --- a/src/PythonAPI/unit_test_experiment/test.py +++ /dev/null @@ -1,8 +0,0 @@ -import unittest - -class Test(unittest.TestCase): - def test_assert_false(self): - self.assertFalse(False) - -if __name__ == "__main__": - unittest.main() -- 2.39.2