Package test_suite :: Package unit_tests :: Package _prompt :: Module test_value
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._prompt.test_value

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2008,2012,2019 Edward d'Auvergne                         # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  6  #                                                                             # 
  7  # This program is free software: you can redistribute it and/or modify        # 
  8  # it under the terms of the GNU General Public License as published by        # 
  9  # the Free Software Foundation, either version 3 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # This program is distributed in the hope that it will be useful,             # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of              # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               # 
 15  # GNU General Public License for more details.                                # 
 16  #                                                                             # 
 17  # You should have received a copy of the GNU General Public License           # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.       # 
 19  #                                                                             # 
 20  ############################################################################### 
 21   
 22  # Python module imports. 
 23  from unittest import TestCase 
 24   
 25  # relax module imports. 
 26  from prompt.interpreter import Interpreter 
 27  from lib.errors import RelaxStrError, RelaxStrListStrError, RelaxValListValError 
 28  from test_suite.unit_tests.value_testing_base import Value_base_class 
 29   
 30  # Unit test imports. 
 31  from test_suite.unit_tests._prompt.data_types import DATA_TYPES 
 32   
 33   
34 -class Test_value(Value_base_class, TestCase):
35 """Unit tests for the functions of the 'prompt.value' module.""" 36
37 - def __init__(self, methodName=None):
38 """Set up the test case class for the system tests.""" 39 40 # Execute the base __init__ methods. 41 super(Test_value, self).__init__(methodName) 42 43 # Load the interpreter. 44 self.interpreter = Interpreter(show_script=False, raise_relax_error=True) 45 self.interpreter.populate_self() 46 self.interpreter.on(verbose=False) 47 48 # Alias the user function class. 49 self.value_fns = self.interpreter.value
50 51
52 - def test_set_argfail_val(self):
53 """The val arg test of the value.set() user function.""" 54 55 # Set the current data pipe to 'mf'. 56 self.interpreter.pipe.switch('mf') 57 58 # Loop over the data types. 59 allowed_params = ['s2', 's2f', 's2s', 'te', 'ts', 'tf', 'rex', 'csa'] 60 for data in DATA_TYPES: 61 # Skip empty lists. 62 if data[0] in ['list']: 63 continue 64 65 # Make sure the param and val argument match. 66 param = 'csa' 67 if data[0] in ['file list', 'float list', 'int list', 'list', 'none list', 'number list', 'str list']: 68 param = [] 69 for i in range(len(data[1])): 70 param.append(allowed_params[i]) 71 if not len(param): 72 param = 'csa' 73 74 # Everything is allowed. 75 self.value_fns.set(val=data[1], param=param)
76 77
78 - def test_set_argfail_param(self):
79 """The param arg test of the value.set() user function.""" 80 81 # Loop over the data types. 82 for data in DATA_TYPES: 83 # Catch the None, str, and str list arguments, and skip them. 84 if data[0] == 'None' or data[0] == 'str' or data[0] == 'str list': 85 continue 86 87 # The argument test. 88 self.assertRaises(RelaxStrListStrError, self.value_fns.set, param=data[1], val=None)
89 90
91 - def test_set_argfail_spin_id(self):
92 """The spin_id arg test of the value.set() user function.""" 93 94 # Loop over the data types. 95 for data in DATA_TYPES: 96 # Catch the None and str arguments, and skip them. 97 if data[0] == 'None' or data[0] == 'str': 98 continue 99 100 # The argument test. 101 self.assertRaises(RelaxStrError, self.value_fns.set, spin_id=data[1])
102