From: Renaud NEDELEC Date: Wed, 14 Oct 2015 14:43:27 +0000 (+0200) Subject: [PythonAPI] added tests in the standard way for Shaper X-Git-Tag: V_2.1.0~206^2~99 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3260a024035b3b8745d26b3821cc7206586b4798;p=modules%2Fshaper.git [PythonAPI] added tests in the standard way for Shaper --- 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/Test/CMakeLists.txt b/src/PythonAPI/Test/CMakeLists.txt new file mode 100644 index 000000000..c42456c7c --- /dev/null +++ b/src/PythonAPI/Test/CMakeLists.txt @@ -0,0 +1,2 @@ +enable_testing() +add_test(NAME "test_modeler" COMMAND "python" "modeler_test_case.py") diff --git a/src/PythonAPI/Test/TestModeler.py b/src/PythonAPI/Test/TestModeler.py new file mode 100644 index 000000000..347aa5afe --- /dev/null +++ b/src/PythonAPI/Test/TestModeler.py @@ -0,0 +1,18 @@ +import unittest +import modeler + +class ModelerTestCase(unittest.TestCase): + def setUp(self): + modeler.begin() + partset = modeler.moduleDocument() + self.part = modeler.addPart(partset).document() + + def tearDown(self): + modeler.end() + + def test_add_sketch(self): + plane = modeler.defaultPlane("XOY") + modeler.addSketch(self.part, plane) + +if __name__ == "__main__": + unittest.main() 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/Test/test_sketcher.py b/src/PythonAPI/Test/test_sketcher.py new file mode 100644 index 000000000..b1f641b31 --- /dev/null +++ b/src/PythonAPI/Test/test_sketcher.py @@ -0,0 +1,14 @@ +import unittest +import modeler + +class TestSketcher(unittest.TestCase): + def test_init_sketch(self): + modeler.begin() + partset = modeler.moduleDocument() + part = modeler.addPart(partset).document() + plane = modeler.defaultPlane("XOY") + modeler.addSketch(part, plane) + modeler.end() + +if __name__ == "__main__": + unittest.main() diff --git a/src/PythonAPI/modeler/tests/CMakeLists.txt b/src/PythonAPI/modeler/tests/CMakeLists.txt deleted file mode 100644 index c42456c7c..000000000 --- a/src/PythonAPI/modeler/tests/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -enable_testing() -add_test(NAME "test_modeler" COMMAND "python" "modeler_test_case.py") diff --git a/src/PythonAPI/modeler/tests/modeler_test_case.py b/src/PythonAPI/modeler/tests/modeler_test_case.py deleted file mode 100644 index 347aa5afe..000000000 --- a/src/PythonAPI/modeler/tests/modeler_test_case.py +++ /dev/null @@ -1,18 +0,0 @@ -import unittest -import modeler - -class ModelerTestCase(unittest.TestCase): - def setUp(self): - modeler.begin() - partset = modeler.moduleDocument() - self.part = modeler.addPart(partset).document() - - def tearDown(self): - modeler.end() - - def test_add_sketch(self): - plane = modeler.defaultPlane("XOY") - modeler.addSketch(self.part, plane) - -if __name__ == "__main__": - unittest.main() diff --git a/src/PythonAPI/modeler/tests/test_sketcher.py b/src/PythonAPI/modeler/tests/test_sketcher.py deleted file mode 100644 index b1f641b31..000000000 --- a/src/PythonAPI/modeler/tests/test_sketcher.py +++ /dev/null @@ -1,14 +0,0 @@ -import unittest -import modeler - -class TestSketcher(unittest.TestCase): - def test_init_sketch(self): - modeler.begin() - partset = modeler.moduleDocument() - part = modeler.addPart(partset).document() - plane = modeler.defaultPlane("XOY") - modeler.addSketch(part, plane) - modeler.end() - -if __name__ == "__main__": - unittest.main() 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()