Salome HOME
Updated CEA python tests.
authorClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 15 Mar 2017 12:58:55 +0000 (13:58 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 15 Mar 2017 12:58:55 +0000 (13:58 +0100)
test.API/SHAPER/GDML/TestAPI_ConeSegment.py
test.API/SHAPER/GDML/TestConeSegment.py
test.API/SHAPER/Primitives/TestAPI_Box.py

index 59a58dde36c96890cf5edd6c5cd3fb7db50eb583..219cb9e09446bea66c2eb58fa3cdad783c021cdd 100644 (file)
@@ -1,85 +1,55 @@
-# Copyright (C) 2014-2016 CEA/DEN, EDF R&D
-
-# File:        TestAPI_Box.py
-# Created:     29 Nov 2016
-# Author:      Clarisse Genrault (CEA)
-
+"""
+Test case for GDML Cone Segment feature. 
+Written on Shape API.
+"""
 from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
 from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
 from GeomAPI import GeomAPI_Pnt as pnt
 
-# Create several "cone segment"
-try :    
-  CS1 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,0.,270.)
-except myExcept,ec:
-  print ec.what()
-  
-try :    
-  CS2 = shaperpy.makeConeSegment(5.,10.,7.,15.,15.,45.,180.)
-except myExcept,ec:
-  print ec.what()
-
-try :    
-  CS3 = shaperpy.makeConeSegment(5.,10.,7.,15.,15.,-45.,180.)
-except myExcept,ec:
-  print ec.what()
-  
-try :    
-  CS4 = shaperpy.makeConeSegment(0.,10.,2.,7.,3.,0.,270.)
-except myExcept,ec:
-  print ec.what()
-
-try :    
-  CS5 = shaperpy.makeConeSegment(5.,8.,0.,6.,10.,45.,270.)
-except myExcept,ec:
-  print ec.what()
-
-try :    
-  CS6 = shaperpy.makeConeSegment(0.,6.,0.,4.,17.,0.,270.)
-except myExcept,ec:
-  print ec.what()
-
-try :    
-  CS7 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,0.,360.)
-except myExcept,ec:
-  print ec.what()
+CS1 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,0.,270.)
+CS2 = shaperpy.makeConeSegment(5.,10.,7.,15.,15.,45.,180.)
+CS3 = shaperpy.makeConeSegment(5.,10.,7.,15.,15.,-45.,180.)
+CS4 = shaperpy.makeConeSegment(0.,10.,2.,7.,3.,0.,270.)
+CS5 = shaperpy.makeConeSegment(5.,8.,0.,6.,10.,45.,270.)
+CS6 = shaperpy.makeConeSegment(0.,6.,0.,4.,17.,0.,270.)
+CS7 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,0.,360.)
 
-try :    
-  CS8 = shaperpy.makeConeSegment(-5.,11.,5.,8.,12.,0.,270.)
+try :
+    CS8 = shaperpy.makeConeSegment(-5.,11.,5.,8.,12.,0.,270.)
 except myExcept,ec:
-  print ec.what()
+    assert(ec.what() == "Cone Segment builder :: rmin1 is negative.")
 
-try :    
-  CS9 = shaperpy.makeConeSegment(11.,7.,5.,8.,12.,0.,270.)
+try :
+    CS9 = shaperpy.makeConeSegment(11.,7.,5.,8.,12.,0.,270.)
 except myExcept,ec:
-  print ec.what()
+    assert(ec.what() == "Cone Segment builder :: rmin1 is larger than rmax1.")
 
-try :    
-  CS10 = shaperpy.makeConeSegment(7.,11.,8.,5.,12.,0.,270.)
+try :
+    CS10 = shaperpy.makeConeSegment(7.,11.,8.,5.,12.,0.,270.)
 except myExcept,ec:
-  print ec.what()
+    assert(ec.what() == "Cone Segment builder :: rmin2 is larger than rmax2.")
 
-try :    
-  CS11 = shaperpy.makeConeSegment(7.,11.,-3.,5.,12.,0.,270.)
+try :
+    CS11 = shaperpy.makeConeSegment(7.,11.,-3.,5.,12.,0.,270.)
 except myExcept,ec:
-  print ec.what()
+    assert(ec.what() == "Cone Segment builder :: rmin2 is negative.")
 
-try :    
-  CS12 = shaperpy.makeConeSegment(7.,11.,5.,8.,0.,0.,270.)
+try :
+    CS12 = shaperpy.makeConeSegment(7.,11.,5.,8.,0.,0.,270.)
 except myExcept,ec:
-  print ec.what()
+    assert(ec.what() == "Cone Segment builder :: z is negative or null.")
 
-try :    
-  CS13 = shaperpy.makeConeSegment(7.,11.,5.,8.,-10.,0.,270.)
+try :
+    CS13 = shaperpy.makeConeSegment(7.,11.,5.,8.,-10.,0.,270.)
 except myExcept,ec:
-  print ec.what()
+    assert(ec.what() == "Cone Segment builder :: z is negative or null.")
 
-try :    
-  CS14 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,-45.,-45.)
+try :
+    CS14 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,-45.,-45.)
 except myExcept,ec:
-  print ec.what()
+    assert(ec.what() == "Cone Segment builder :: deltaphi is negative or null.")
 
-try :    
-  CS15 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,45.,450.)
+try :
+    CS15 = shaperpy.makeConeSegment(7.,11.,5.,8.,12.,45.,450.)
 except myExcept,ec:
-  print ec.what()
\ No newline at end of file
+    assert(ec.what() == "Cone Segment builder :: deltaphi is larger than 360 degree.")
index d58b45ad61490a376fd86e6508c61f76d9ef8145..f96a7574d1f06145d9888202d56d533523647793 100644 (file)
 Test case for GDML Primitive Cone Segment feature. 
 Written on High API.
 """
-from ModelAPI import *
-from GeomAPI import *
-
 from salome.shaper import model
 
-# Get session
-aSession = ModelAPI_Session.get()
-
-# Create a part
-aDocument = aSession.activeDocument()
-aSession.startOperation()
-model.addPart(aDocument)
-aDocument = aSession.activeDocument()
-aSession.finishOperation()
-
-# Create several "cone segment"
-aSession.startOperation()
-aCS1 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,0.,270.).result()
-aSession.finishOperation()
-assert (aCS1 is not None)
-
-aSession.startOperation()
-aCS2 = model.addConeSegment(aDocument,5.,10.,7.,15.,15.,45.,180.).result()
-aSession.finishOperation()
-assert (aCS2 is not None)
-
-aSession.startOperation()
-aCS3 = model.addConeSegment(aDocument,5.,10.,7.,15.,15.,-45.,180.).result()
-aSession.finishOperation()
-assert (aCS3 is not None)
-
-aSession.startOperation()
-aCS4 = model.addConeSegment(aDocument,0.,10.,2.,7.,3.,0.,270.).result()
-aSession.finishOperation()
-assert (aCS4 is not None)
-
-aSession.startOperation()
-aCS5 = model.addConeSegment(aDocument,5.,8.,0.,6.,10.,45.,270.).result()
-aSession.finishOperation()
-assert (aCS5 is not None)
-
-aSession.startOperation()
-aCS6 = model.addConeSegment(aDocument,0.,6.,0.,4.,17.,0.,270.).result()
-aSession.finishOperation()
-assert (aCS6 is not None)
-
-aSession.startOperation()
-aCS7 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,0.,360.).result()
-aSession.finishOperation()
-assert (aCS7 is not None)
-
-aSession.startOperation()
-aCS8 = model.addConeSegment(aDocument,-5.,11.,5.,8.,12.,0.,270.)
-aSession.finishOperation()
-assert (len(aCS8.results()) == 0)
-
-aSession.startOperation()
-aCS9 = model.addConeSegment(aDocument,11.,7.,5.,8.,12.,0.,270.)
-aSession.finishOperation()
-assert (len(aCS9.results()) == 0)
-
-aSession.startOperation()
-aCS10 = model.addConeSegment(aDocument,7.,11.,8.,5.,12.,0.,270.)
-aSession.finishOperation()
-assert (len(aCS10.results()) == 0)
-
-aSession.startOperation()
-aCS11 = model.addConeSegment(aDocument,7.,11.,-3.,5.,12.,0.,270.)
-aSession.finishOperation()
-assert (len(aCS11.results()) == 0)
-
-aSession.startOperation()
-aCS12 = model.addConeSegment(aDocument,7.,11.,5.,8.,0.,0.,270.)
-aSession.finishOperation()
-assert (len(aCS12.results()) == 0)
-
-aSession.startOperation()
-aCS13 = model.addConeSegment(aDocument,7.,11.,5.,8.,-10.,0.,270.)
-aSession.finishOperation()
-assert (len(aCS13.results()) == 0)
-
-aSession.startOperation()
-aCS14 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,-45.,-45.)
-aSession.finishOperation()
-assert (len(aCS14.results()) == 0)
-
-aSession.startOperation()
-aCS15 = model.addConeSegment(aDocument,7.,11.,5.,8.,12.,45.,450.)
-aSession.finishOperation()
-assert (len(aCS15.results()) == 0)
-
-aSession.startOperation()
-model.addParameter(aDocument,"rmin1","7.")
-model.addParameter(aDocument,"rmax1","11.")
-model.addParameter(aDocument,"rmin2","5.")
-model.addParameter(aDocument,"rmax2","8.")
-model.addParameter(aDocument,"z","12.")
-model.addParameter(aDocument,"startphi","0.")
-model.addParameter(aDocument,"deltaphi","270.")
-aCS16 = model.addConeSegment(aDocument,"rmin1","rmax1","rmin2","rmax2","z","startphi","deltaphi").result()
-aSession.finishOperation()
-assert (aCS16 is not None)
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+# Parameters
+model.addParameter(Part_1_doc, "rmin1", "7")
+model.addParameter(Part_1_doc, "rmax1", "11")
+model.addParameter(Part_1_doc, "rmin2", "5")
+model.addParameter(Part_1_doc, "rmax2", "8")
+model.addParameter(Part_1_doc, "z", "12")
+model.addParameter(Part_1_doc, "startphi", "0")
+model.addParameter(Part_1_doc, "deltaphi", "270")
+
+# Tests
+CS1 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, 0 , 270)
+CS2 = model.addConeSegment(Part_1_doc, 5, 10, 7, 15, 15, 45 , 180)
+CS3 = model.addConeSegment(Part_1_doc, 5, 10, 7, 15, 15, -45 , 180)
+CS4 = model.addConeSegment(Part_1_doc, 0, 10, 2, 7, 3, 0 , 270)
+CS5 = model.addConeSegment(Part_1_doc, 5, 8, 0, 6, 10, 45 , 270)
+CS6 = model.addConeSegment(Part_1_doc, 0, 6, 0, 4, 17, 0 , 270)
+CS7 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, 0 , 360)
+CS8 = model.addConeSegment(Part_1_doc, -5, 11, 5, 8, 12, 0 , 270)
+CS9 = model.addConeSegment(Part_1_doc, 11, 7, 5, 8, 12, 0 , 270)
+CS10 = model.addConeSegment(Part_1_doc, 7, 11, 8, 5, 12, 0 , 270)
+CS11 = model.addConeSegment(Part_1_doc, 7, 11, -3, 5, 12, 0 , 270)
+CS12 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 0, 0 , 270)
+CS13 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, -10, 0 , 270)
+CS14 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, -45 , -45)
+CS15 = model.addConeSegment(Part_1_doc, 7, 11, 5, 8, 12, 45 , 450)
+CS16 = model.addConeSegment(Part_1_doc, "rmin1", "rmax1", "rmin2", "rmax2", "z", "startphi" , "deltaphi")
+model.do()
+model.end()
+
+# Checks
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(CS1, 1)
+model.testNbSubResults(CS1, [0])
+model.testNbSubShapes(CS1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(CS1, GeomAPI_Shape.FACE, [6])
+model.testHaveNamingFaces(CS1, model, Part_1_doc)
+
+model.testNbResults(CS2, 1)
+model.testNbSubResults(CS2, [0])
+model.testNbSubShapes(CS2, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(CS2, GeomAPI_Shape.FACE, [6])
+model.testHaveNamingFaces(CS2, model, Part_1_doc)
+
+model.testNbResults(CS3, 1)
+model.testNbSubResults(CS3, [0])
+model.testNbSubShapes(CS3, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(CS3, GeomAPI_Shape.FACE, [6])
+model.testHaveNamingFaces(CS3, model, Part_1_doc)
+
+model.testNbResults(CS4, 1)
+model.testNbSubResults(CS4, [0])
+model.testNbSubShapes(CS4, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(CS4, GeomAPI_Shape.FACE, [6])
+model.testHaveNamingFaces(CS4, model, Part_1_doc)
+
+model.testNbResults(CS5, 1)
+model.testNbSubResults(CS5, [0])
+model.testNbSubShapes(CS5, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(CS5, GeomAPI_Shape.FACE, [6])
+model.testHaveNamingFaces(CS5, model, Part_1_doc)
+
+model.testNbResults(CS6, 1)
+model.testNbSubResults(CS6, [0])
+model.testNbSubShapes(CS6, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(CS6, GeomAPI_Shape.FACE, [5])
+model.testHaveNamingFaces(CS6, model, Part_1_doc)
+
+model.testNbResults(CS7, 1)
+model.testNbSubResults(CS7, [0])
+model.testNbSubShapes(CS7, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(CS7, GeomAPI_Shape.FACE, [4])
+model.testHaveNamingFaces(CS7, model, Part_1_doc)
+
+model.testNbResults(CS16, 1)
+model.testNbSubResults(CS16, [0])
+model.testNbSubShapes(CS16, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(CS16, GeomAPI_Shape.FACE, [6])
+model.testHaveNamingFaces(CS16, model, Part_1_doc)
+
+model.testNbResults(CS8, 0)
+assert(CS8.feature().error() == "Cone Segment builder :: rmin1 is negative.")
+
+model.testNbResults(CS9, 0)
+assert(CS9.feature().error() == "Cone Segment builder :: rmin1 is larger than rmax1.")
+
+model.testNbResults(CS10, 0)
+assert(CS10.feature().error() == "Cone Segment builder :: rmin2 is larger than rmax2.")
+
+model.testNbResults(CS11, 0)
+assert(CS11.feature().error() == "Cone Segment builder :: rmin2 is negative.")
+
+model.testNbResults(CS12, 0)
+assert(CS12.feature().error() == "Cone Segment builder :: z is negative or null.")
+
+model.testNbResults(CS13, 0)
+assert(CS13.feature().error() == "Cone Segment builder :: z is negative or null.")
+
+model.testNbResults(CS14, 0)
+assert(CS14.feature().error() == "Cone Segment builder :: deltaphi is negative or null.")
+
+model.testNbResults(CS15, 0)
+assert(CS15.feature().error() == "Cone Segment builder :: deltaphi is larger than 360 degree.")
\ No newline at end of file
index 92f66dca1987b8c56e83d37847fc962776d6742d..5c73e24e51ac961cfebbffe6dee76a25be245417 100644 (file)
@@ -1,9 +1,7 @@
-# Copyright (C) 2014-2016 CEA/DEN, EDF R&D
-
-# File:        TestAPI_Box.py
-# Created:     16 Sept 2016
-# Author:      Clarisse Genrault (CEA)
-
+"""
+Test case for Primitive Box feature. 
+Written on Shape API.
+"""
 from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
 from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
 from GeomAPI import GeomAPI_Pnt as pnt