Back to index

salome-paravis  6.5.0
Classes | Functions | Variables
paravistest Namespace Reference

Classes

class  RepresentationType
class  SalomeSession

Functions

def test_values
def get_picture_dir
def call_and_check
def setShaded

Variables

tuple samples_dir = os.getenv("DATA_DIR")
 datadir = None
 tablesdir = None
tuple pictureext = os.getenv("PIC_EXT")
tuple salome_session = SalomeSession()
tuple aStudy = salome.myStudyManager.NewStudy("Study1")

Function Documentation

def paravistest.call_and_check (   prs,
  property_name,
  value,
  do_raise = 1,
  compare_toler = -1.0 
)
Utility function for 3D viewer test for common check of different
types of presentation parameters set

Definition at line 148 of file paravistest.py.

00148 
00149 def call_and_check(prs, property_name, value, do_raise=1, compare_toler=-1.0):
00150     """Utility function for 3D viewer test for common check of different
00151     types of presentation parameters set"""
00152     try:
00153         prs.SetPropertyWithName(property_name, value)
00154     except ValueError:
00155         error_string = (str(value) + "value of " + property_name + " is not available for this type of presentations")
00156     else:
00157         error_string = None
00158     is_good = (error_string is None)
00159     if not is_good:
00160         if do_raise:
00161             raise RuntimeError(error_string)
00162         else:
00163             print error_string
00164     else:
00165         # compare just set value and the one got from presentation
00166         really_set_value = prs.GetPropertyValue(property_name)
00167         is_equal = 1
00168         if compare_toler > 0:
00169             is_equal = (fabs(really_set_value - value) < compare_toler)
00170         else:
00171             is_equal = (really_set_value == value)
00172         if not is_equal:
00173             msg = str(really_set_value) + " has been set instead"
00174             if do_raise:
00175                 raise RuntimeError(msg)
00176             else:
00177                 print msg
00178                 is_good = False
00179 
00180     return is_good
00181 

def paravistest.get_picture_dir (   pic_dir,
  subdir 
)

Definition at line 127 of file paravistest.py.

00127 
00128 def get_picture_dir(pic_dir, subdir):
00129     res_dir = pic_dir
00130     if not res_dir:
00131         res_dir = "/tmp/pic"
00132 
00133     # Add current date and subdirectory for the case to the directory path
00134     cur_date = date.today().strftime("%d%m%Y")
00135     res_dir += "/test_" + cur_date + "/" + subdir
00136     # Create the directory if doesn't exist
00137     res_dir = os.path.normpath(res_dir)
00138     if not os.path.exists(res_dir):
00139         os.makedirs(res_dir)
00140     else:
00141         # Clean the directory
00142         for root, dirs, files in os.walk(res_dir):
00143             for f in files:
00144                 os.remove(os.path.join(root, f))
00145 
00146     return res_dir
00147 

def paravistest.setShaded (   view,
  shading 
)
Utility function to set shaded mode in view

Definition at line 182 of file paravistest.py.

00182 
00183 def setShaded(view, shading):
00184     """Utility function to set shaded mode in view"""
00185     if shading == 0:
00186         view.LightDiffuseColor = [1, 1, 1]
00187     if shading == 1:
00188         view.LightDiffuseColor = [0, 0, 0]
00189 
00190 
# Run Salome
def paravistest.test_values (   value,
  et_value,
  check_error = 0 
)
Test values.

Definition at line 98 of file paravistest.py.

00098 
00099 def test_values(value, et_value, check_error=0):
00100     """Test values."""
00101     error = 0
00102     length = len(value)
00103     et_length = len(et_value)
00104     if (length != et_length):
00105         err_msg = "ERROR!!! There is different number of created " + str(length) + " and etalon " + str(et_length) + " values!!!"
00106         print err_msg
00107         error = error + 1
00108     else:
00109         for i in range(et_length):
00110             if abs(et_value[i]) > 1:
00111                 max_val = abs(0.001 * et_value[i])
00112                 if abs(et_value[i] - value[i]) > max_val:
00113                     err_msg = "ERROR!!! Got value " + str(value[i]) + " is not equal to etalon value " + str(ret_value[i]) + "!!!"
00114                     print err_msg
00115                     error = error + 1
00116             else:
00117                 max_val = 0.001
00118                 if abs(et_value[i] - value[i]) > max_val:
00119                     err_msg = "ERROR!!! Got value " + value[i] + " is not equal to etalon value " + et_value[i] + "!!!"
00120                     error = error + 1
00121     if check_error and error > 0:
00122         err_msg = ("There is(are) some error(s) was(were) found... "
00123                    "For more info see ERRORs above...")
00124         raise RuntimeError(err_msg)
00125     return error
00126 


Variable Documentation

tuple paravistest.aStudy = salome.myStudyManager.NewStudy("Study1")

Definition at line 196 of file paravistest.py.

string paravistest.datadir = None

Definition at line 37 of file paravistest.py.

string paravistest.pictureext = os.getenv("PIC_EXT")

Definition at line 45 of file paravistest.py.

Definition at line 191 of file paravistest.py.

tuple paravistest.samples_dir = os.getenv("DATA_DIR")

Definition at line 36 of file paravistest.py.

string paravistest.tablesdir = None

Definition at line 38 of file paravistest.py.