Salome HOME
Merge with Dev_1.5.0
[modules/shaper.git] / src / PythonAPI / Test / TestSketcherSetEqual.py
1 import unittest
2 import model
3 import math
4 import TestSketcher
5 from TestSketcher import SketcherTestCase
6
7 class SketcherSetEqual(SketcherTestCase):
8     def test_length_equality(self):
9         # Set the constraint
10         l1 = self.sketch.addLine(0, 0, 0, 1)
11         l2 = self.sketch.addLine(0, 0, 1, 1)
12         self.sketch.setEqual(l1.result(), l2.result())
13         # Commit the transaction
14         model.do()
15         # Check the result
16         length_1 = math.sqrt(
17             math.pow((l1.endPointData().x() - l1.startPointData().x()), 2) +
18             math.pow((l1.endPointData().y() - l1.startPointData().y()), 2)
19             )
20         length_2 = math.sqrt(
21             math.pow((l2.endPointData().x() - l2.startPointData().x()), 2) +
22             math.pow((l2.endPointData().y() - l2.startPointData().y()), 2)
23             )
24         self.assertAlmostEqual(length_1, length_2, delta=TestSketcher.DELTA)
25
26     def test_radius_equality(self):
27         # Set the constraint
28         circle_1 = self.sketch.addCircle(0, 0, 10.0)
29         circle_2 = self.sketch.addCircle(1, 2, 25.0)
30         self.sketch.setEqual(circle_1.result(), circle_2.result())
31         # Commit the transaction
32         model.do()
33         # Check the result
34         self.assertAlmostEqual(
35             circle_1.radiusData().value(),
36             circle_2.radiusData().value(),
37             delta=TestSketcher.DELTA
38             )
39
40 if __name__ == "__main__":
41     suite = unittest.TestLoader().loadTestsFromTestCase(SketcherSetEqual)
42     unittest.TextTestRunner(verbosity=2).run(suite)