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

Source Code for Module test_suite.unit_tests._prompt.test_state

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2007-2014 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 test_suite.unit_tests.state_testing_base import State_base_class 
 28  from lib.errors import RelaxBoolError, RelaxIntError, RelaxNoneStrError, RelaxStrFileError 
 29   
 30  # Unit test imports. 
 31  from test_suite.unit_tests._prompt.data_types import DATA_TYPES 
 32   
 33    
34 -class Test_state(State_base_class, TestCase):
35 """Unit tests for the functions of the 'prompt.state' 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_state, 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.state = self.interpreter.state 50 51 # Alias the user functions to work with the backend. 52 self.state.load_state = self.state.load 53 self.state.save_state = self.state.save
54 55
56 - def test_load_argfail_state(self):
57 """Test the proper failure of the state.load() user function for the state argument.""" 58 59 # Loop over the data types. 60 for data in DATA_TYPES: 61 # Catch the str and file arguments, and skip them. 62 if data[0] == 'str' or data[0] == 'file': 63 continue 64 65 # The argument test. 66 self.assertRaises(RelaxStrFileError, self.state.load_state, state=data[1])
67 68
69 - def test_load_argfail_dir(self):
70 """Test the proper failure of the state.load() user function for the dir argument.""" 71 72 # Loop over the data types. 73 for data in DATA_TYPES: 74 # Catch the None and str arguments, and skip them. 75 if data[0] == 'None' or data[0] == 'str': 76 continue 77 78 # The argument test. 79 self.assertRaises(RelaxNoneStrError, self.state.load_state, state='a', dir=data[1])
80 81
82 - def test_save_argfail_state(self):
83 """Test the proper failure of the state.save() user function for the state argument.""" 84 85 # Loop over the data types. 86 for data in DATA_TYPES: 87 # Catch the str and file arguments, and skip them. 88 if data[0] == 'str' or data[0] == 'file': 89 continue 90 91 # The argument test. 92 self.assertRaises(RelaxStrFileError, self.state.save_state, state=data[1])
93 94
95 - def test_save_argfail_dir(self):
96 """Test the proper failure of the state.save() user function for the dir argument.""" 97 98 # Loop over the data types. 99 for data in DATA_TYPES: 100 # Catch the None and str arguments, and skip them. 101 if data[0] == 'None' or data[0] == 'str': 102 continue 103 104 # The argument test. 105 self.assertRaises(RelaxNoneStrError, self.state.save_state, state='a', dir=data[1])
106 107
108 - def test_save_argfail_force(self):
109 """Test the proper failure of the state.save() user function for the force argument.""" 110 111 # Loop over the data types. 112 for data in DATA_TYPES: 113 # Catch the bool arguments, and skip them. 114 if data[0] == 'bool': 115 continue 116 117 # The argument test. 118 self.assertRaises(RelaxBoolError, self.state.save_state, state='a', force=data[1])
119 120
122 """Test the proper failure of the state.save() user function for the compress_type argument.""" 123 124 # Loop over the data types. 125 for data in DATA_TYPES: 126 # Catch the int and bin arguments, and skip them. 127 if data[0] == 'int' or data[0] == 'bin': 128 continue 129 130 # The argument test. 131 self.assertRaises(RelaxIntError, self.state.save_state, state='a', compress_type=data[1])
132