Salome HOME
[PythonAPI / sketcher] added the setEqual method and the setLength test
[modules/shaper.git] / src / PythonAPI / Test / TestSketcherSetLength.py
diff --git a/src/PythonAPI/Test/TestSketcherSetLength.py b/src/PythonAPI/Test/TestSketcherSetLength.py
new file mode 100644 (file)
index 0000000..b56650b
--- /dev/null
@@ -0,0 +1,22 @@
+import unittest
+import model
+import math
+import TestSketcher
+from TestSketcher import SketcherTestCase
+
+class SketcherSetLength(SketcherTestCase):   
+    def runTest(self):
+        # Set the constraint
+        line = self.sketch.addLine(0, 0, 0, 1)
+        self.sketch.setLength(line.result(), 25.0)
+        # Commit the transaction
+        model.do()
+        # Check the result
+        length = math.sqrt(
+            math.pow((line.endPointData().x() - line.startPointData().x()), 2) + 
+            math.pow((line.endPointData().y() - line.startPointData().y()), 2)
+            )
+        self.assertAlmostEqual(length, 25.0, delta=TestSketcher.DELTA)
+        
+if __name__ == "__main__":
+    unittest.main()
\ No newline at end of file