From: Christophe Bourcier Date: Thu, 3 Dec 2020 10:09:35 +0000 (+0100) Subject: Update tests X-Git-Tag: V9_7_0a1~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fcbr%2Fmore_fixes_after_960;p=modules%2Fmed.git Update tests --- diff --git a/src/MEDCalc/cmp/test_medcalc_components.py b/src/MEDCalc/cmp/test_medcalc_components.py index fb28d2308..8eb7415dd 100644 --- a/src/MEDCalc/cmp/test_medcalc_components.py +++ b/src/MEDCalc/cmp/test_medcalc_components.py @@ -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()) diff --git a/src/MEDCalc/tui/fields_test.py b/src/MEDCalc/tui/fields_test.py index 9f5ab3669..109cf4369 100644 --- a/src/MEDCalc/tui/fields_test.py +++ b/src/MEDCalc/tui/fields_test.py @@ -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)