]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Update tests cbr/more_fixes_after_960
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Thu, 3 Dec 2020 10:09:35 +0000 (11:09 +0100)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Thu, 3 Dec 2020 10:09:35 +0000 (11:09 +0100)
src/MEDCalc/cmp/test_medcalc_components.py
src/MEDCalc/tui/fields_test.py

index fb28d23081f48d89af1d370c406052afc6f14edb..8eb7415ddf3768012603cce48656f7d98a2eca5b 100644 (file)
@@ -51,7 +51,7 @@
 # containerType = Name of the container factory
 #
 componentName = "MEDFactory"
-corbaModule   = "MEDCalc"
+corbaModule   = "MEDCALC"
 containerType = "FactoryServer"
 
 import salome
@@ -190,10 +190,10 @@ def TEST_saveFields():
 # Use cases of the MEDDataManager for data loading
 # ==================================================
 #
-def TEST_MEDDataManager_getMeshList():
+def TEST_MEDDataManager_getMeshHandlerList():
     dataManager = factory.getDataManager()
     datasourceHandler = dataManager.loadDatasource(testFilePath)
-    meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
+    meshHandlerList = dataManager.getMeshHandlerList(datasourceHandler.id)
     print(meshHandlerList)
 
     if len(meshHandlerList) == 0:
@@ -203,10 +203,10 @@ def TEST_MEDDataManager_getMeshList():
 def TEST_MEDDataManager_getMesh():
     dataManager = factory.getDataManager()
     datasourceHandler = dataManager.loadDatasource(testFilePath)
-    meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
+    meshHandlerList = dataManager.getMeshHandlerList(datasourceHandler.id)
     for mRef in meshHandlerList:
         meshId = mRef.id
-        mRes = dataManager.getMesh(meshId)
+        mRes = dataManager.getMeshHandler(meshId)
         print(mRes)
         if ( mRes.name != mRef.name ) or ( mRes.sourceid != mRef.sourceid):
             return False
@@ -216,7 +216,7 @@ def TEST_MEDDataManager_getFieldseriesListOnMesh():
     dataManager = factory.getDataManager()
     datasourceHandler = dataManager.loadDatasource(testFilePath)
 
-    meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
+    meshHandlerList = dataManager.getMeshHandlerList(datasourceHandler.id)
     # We look for the fieldseries defined on the first mesh of the list
     meshId = meshHandlerList[0].id
     fieldseriesList = dataManager.getFieldseriesListOnMesh(meshId)
@@ -233,7 +233,7 @@ def TEST_MEDDataManager_getFieldListInFieldseries():
     testFilePath  = getFilePath("timeseries.med")
     datasourceHandler = dataManager.loadDatasource(testFilePath)
 
-    meshHandlerList = dataManager.getMeshList(datasourceHandler.id)
+    meshHandlerList = dataManager.getMeshHandlerList(datasourceHandler.id)
     # We look for the fieldseries defined on the first mesh of the list
     meshId = meshHandlerList[0].id
     fieldseriesList = dataManager.getFieldseriesListOnMesh(meshId)
@@ -247,6 +247,37 @@ def TEST_MEDDataManager_getFieldListInFieldseries():
         return False
     return True
 
+def TEST_MEDDataManager_getFieldIdAtTimestamp():
+    dataManager = factory.getDataManager()
+    testFilePath = os.path.join(RESDIR,testFileName)
+
+    testFilePath  = getFilePath("timeseries.med")
+    datasourceHandler = dataManager.loadDatasource(testFilePath)
+
+    meshHandlerList = dataManager.getMeshHandlerList(datasourceHandler.id)
+    # We look for the fieldseries defined on the first mesh of the list
+    meshId = meshHandlerList[0].id
+    fieldseriesList = dataManager.getFieldseriesListOnMesh(meshId)
+    # We look for the fields defined in the first fieldseries,
+    # i.e. the time steps for this field.
+    fieldseriesId = fieldseriesList[0].id
+    requestedTimestamp8 = 8
+    fieldId8 = dataManager.getFieldIdAtTimestamp(fieldseriesId, requestedTimestamp8)
+    timestamp8 = dataManager.getFieldTimestamp(fieldId8)
+    print("fieldId8: ", fieldId8)
+    print("timestamp8: ", timestamp8)
+    requestedTimestamp9 = 9
+    fieldId9 = dataManager.getFieldIdAtTimestamp(fieldseriesId, 9)
+    timestamp9 = dataManager.getFieldTimestamp(fieldId9)
+    print("fieldId9: ", fieldId9)
+    print("timestamp9: ", timestamp9)
+
+    if (timestamp8!=requestedTimestamp8):
+      return False
+    if (timestamp9!=requestedTimestamp9):
+      return False
+    return True
+
 #
 # ==================================================
 # Use cases of the MEDCalculator
@@ -352,8 +383,8 @@ class MyTestSuite(unittest.TestCase):
         self.assertTrue(TEST_saveFields())
 
     # === MEDDataManager (data request functions)
-    def test_MEDDataManager_getMeshList(self):
-        self.assertTrue(TEST_MEDDataManager_getMeshList())
+    def test_MEDDataManager_getMeshHandlerList(self):
+        self.assertTrue(TEST_MEDDataManager_getMeshHandlerList())
 
     def test_MEDDataManager_getMesh(self):
         self.assertTrue(TEST_MEDDataManager_getMesh())
@@ -364,6 +395,9 @@ class MyTestSuite(unittest.TestCase):
     def test_MEDDataManager_getFieldListInFieldseries(self):
         self.assertTrue(TEST_MEDDataManager_getFieldListInFieldseries())
 
+    def test_MEDDataManager_getFieldIdAtTimestamp(self):
+        self.assertTrue(TEST_MEDDataManager_getFieldIdAtTimestamp())
+
     # === MEDCalculator (need MEDDataManager)
     def test_Calculator_basics(self):
         self.assertTrue(TEST_Calculator_basics())
index 9f5ab3669334b122ef0c728a7b852757b5faf0c9..109cf4369183ba9e9586a019db883a65a52b588e 100644 (file)
@@ -117,4 +117,8 @@ class TestFields(unittest.TestCase):
         self.processGuiEvents()
 
 if __name__ == '__main__':
-    unittest.main()
+    exit = True
+    # Keep Salome GUI alive
+    if salome.sg.hasDesktop():
+      exit=False
+    unittest.main(exit=exit)