]> SALOME platform Git repositories - tools/ydefx.git/commitdiff
Salome HOME
Fix available resources in no salome server mode.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Tue, 8 Oct 2019 14:07:00 +0000 (16:07 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Tue, 8 Oct 2019 14:07:00 +0000 (16:07 +0200)
src/pydefx/configuration.py
src/pydefx/salome_proxy.py
src/pyexample/CMakeLists.txt
src/pyexample/runUnitTest.sh
src/pyexample/test_default.py [new file with mode: 0644]
src/pyexample/tests1.py

index 591b3e6be72d74545ecf694ea34044ca4acbaca1..34efb55ee3efae3e4dfb49cd116225261f14e45f 100644 (file)
@@ -51,6 +51,6 @@ def defaultWckey(resource="localhost"):
 
 def availableResources():
   resManager = salome_proxy.getResourcesManager()
-  params     = salome_proxy.createSalomeParameters().resource_required
-  params.can_launch_batch_jobs = True
-  return resManager.GetFittingResources(params)
+  params     = salome_proxy.createSalomeParameters()
+  params.resource_required.can_launch_batch_jobs = True
+  return resManager.GetFittingResources(params.resource_required)
index 906776010629203965a9b302c35fcf7f14d9bcaf..a117bbb496b960e94df5dfcda2a394070841fe04 100644 (file)
@@ -30,7 +30,6 @@ def createSalomeParameters():
     result.resource_required = salome.ResourceParameters()
   else:
     result = pylauncher.JobParameters_cpp()
-    result.resource_required = pylauncher.resourceParams()
   return result
 
 _resourceManager = None
index f00a9b06f1d0f1eca3fea137f50f76c4b16767f8..d61efb42221bf563f9135c57ea266d0d74a0b695 100644 (file)
@@ -25,6 +25,7 @@ IF(SALOME_BUILD_TESTS)
   SET(TESTFILES
   test_insitu.py
   test_prescript.py
+  test_default.py
   )
   INSTALL(FILES ${TESTFILES} DESTINATION ${LOCAL_TEST_DIR})
   INSTALL(PROGRAMS runUnitTest.sh
index fc4d6f1baeaa8aa39dbd41fc5cecb9eb9518dd92..d516d31a48b3a25cce997a01d19d2eafe78103bf 100755 (executable)
@@ -18,6 +18,6 @@
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
-python3 -m unittest test_insitu.py test_prescript.py
+python3 -m unittest test_insitu.py test_prescript.py test_default.py
 ret=$?
 exit $ret
diff --git a/src/pyexample/test_default.py b/src/pyexample/test_default.py
new file mode 100644 (file)
index 0000000..fa0b6e7
--- /dev/null
@@ -0,0 +1,31 @@
+import unittest
+import os
+import time
+
+class TestYdefx(unittest.TestCase):
+  def test_errors(self):
+    """
+    Test errors in study script.
+    """
+    import pydefx
+
+    myScript = pydefx.PyScript()
+    myScript.loadString("a=5")
+    self.assertIn("not accepted statement", myScript.getErrors())
+    
+    myScript.loadString("n'importe quoi!")
+    self.assertIn("SyntaxError", myScript.getErrors())
+
+    myScript.loadString("")
+    self.assertIn("Function _exec not found", myScript.getErrors())
+    
+    with self.assertRaises(pydefx.pyscript.PyScriptException):
+      mySample = myScript.CreateEmptySample()
+
+  def test_availableResources(self):
+    import pydefx
+    lr = pydefx.configuration.availableResources()
+    self.assertIn('localhost', lr) 
+
+if __name__ == '__main__':
+    unittest.main()
index e2d567693823f0be8b33e573acaf2611b1774fe3..1ceb6af8705759711b44f16e97fb3bc8950ae88f 100644 (file)
@@ -23,3 +23,9 @@ print(myStudy.getProgress())
 myStudy.launch()
 print(myStudy.getJobState())
 print(myStudy.getProgress())
+myStudy.wait()
+print(myStudy.getJobState())
+print(myStudy.getProgress())
+myStudy.getResult()
+print(myStudy.sample)
+print(myStudy.global_result)