1 # Copyright (C) 2014-2024 CEA, EDF
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 import salome, salome_utils, os, sys
26 import ModelHighAPI, ModelAPI, PartSetAPI
27 from GeomAPI import GeomAPI_Shape
28 from salome.shaper import model
30 class TestHDF(unittest.TestCase):
36 salome.salome_init(self.testfile, embedded=1, forced=True)
37 myStudyName = salome.myStudy._get_Name()
38 self.session = salome.naming_service.Resolve('/Kernel/Session')
39 self.session.emitMessage("connect_to_study")
41 self.sg = SalomePyQt.SalomePyQt()
42 self.sg.activateModule("Shaper")
43 self.session = ModelAPI.ModelAPI_Session.get()
44 self.partSet = self.session.moduleDocument()
47 salome.sg.UpdateView()
48 self.sg.processEvents()
51 def test_hdf_file(self):
52 self.assertTrue(self.partSet.size("Parts") > 0)
54 for aPartIndex in range(self.partSet.size("Parts")):
55 self.session.startOperation()
56 aPart = ModelAPI.modelAPI_ResultPart(ModelAPI.objectToResult(self.partSet.object("Parts", aPartIndex)))
58 self.session.finishOperation()
60 aPartFeature = PartSetAPI.PartSetAPI_Part(self.partSet.currentFeature(True))
61 aPartsList["Part_{}".format(aPartIndex+1)] = aPartFeature
63 self.session.startOperation()
64 self.session.setActiveDocument(self.partSet)
65 self.session.finishOperation()
67 # Check that the features are not in error
68 Part_1_doc = aPart.partDoc()
70 model.checkFeaturesValidity(Part_1_doc)
71 # check reference data
72 exec(open(self.reffile, "rb").read(), globals(), aPartsList)
75 if __name__ == "__main__":
77 TestHDF.testfile = sys.argv[1]
79 TestHDF.reffile = sys.argv[2]
81 errFile = open(sys.argv[3], 'w')
83 # to ease debugging, display the log in embedded python console if no log file is provided
84 # when calling salome in command line for instance
85 # runSalome.py --splash 0 test_hdf.py args:BearingSeparator.hdf,BearingSeparator.py
88 aTest = unittest.TestLoader().loadTestsFromTestCase(TestHDF)
89 unittest.TextTestRunner(stream=errFile).run(aTest)
93 # Quit SALOME the clean way