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, 2010 Edward d'Auvergne                                  # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax 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 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax 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 relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Python module imports. 
 24  from unittest import TestCase 
 25   
 26  # relax module imports. 
 27  from test_suite.unit_tests.state_testing_base import State_base_class 
 28  from prompt.state import State 
 29  from relax_errors import RelaxBoolError, RelaxIntError, RelaxNoneStrError, RelaxStrFileError 
 30   
 31  # Unit test imports. 
 32  from data_types import DATA_TYPES 
 33   
 34    
35 -class Test_state(State_base_class, TestCase):
36 """Unit tests for the functions of the 'prompt.state' module.""" 37 38 # Instantiate the user function class. 39 state = State() 40 41 # Rename the user functions. 42 state.load_state = state.load 43 state.save_state = state.save 44 45
46 - def test_load_argfail_state(self):
47 """Test the proper failure of the state.load() user function for the state argument.""" 48 49 # Loop over the data types. 50 for data in DATA_TYPES: 51 # Catch the str and file arguments, and skip them. 52 if data[0] == 'str' or data[0] == 'file': 53 continue 54 55 # The argument test. 56 self.assertRaises(RelaxStrFileError, self.state.load_state, state=data[1])
57 58
59 - def test_load_argfail_dir(self):
60 """Test the proper failure of the state.load() user function for the dir argument.""" 61 62 # Loop over the data types. 63 for data in DATA_TYPES: 64 # Catch the None and str arguments, and skip them. 65 if data[0] == 'None' or data[0] == 'str': 66 continue 67 68 # The argument test. 69 self.assertRaises(RelaxNoneStrError, self.state.load_state, state='a', dir=data[1])
70 71
72 - def test_save_argfail_state(self):
73 """Test the proper failure of the state.save() user function for the state argument.""" 74 75 # Loop over the data types. 76 for data in DATA_TYPES: 77 # Catch the str and file arguments, and skip them. 78 if data[0] == 'str' or data[0] == 'file': 79 continue 80 81 # The argument test. 82 self.assertRaises(RelaxStrFileError, self.state.save_state, state=data[1])
83 84
85 - def test_save_argfail_dir(self):
86 """Test the proper failure of the state.save() user function for the dir argument.""" 87 88 # Loop over the data types. 89 for data in DATA_TYPES: 90 # Catch the None and str arguments, and skip them. 91 if data[0] == 'None' or data[0] == 'str': 92 continue 93 94 # The argument test. 95 self.assertRaises(RelaxNoneStrError, self.state.save_state, state='a', dir=data[1])
96 97
98 - def test_save_argfail_force(self):
99 """Test the proper failure of the state.save() user function for the force argument.""" 100 101 # Loop over the data types. 102 for data in DATA_TYPES: 103 # Catch the bool arguments, and skip them. 104 if data[0] == 'bool': 105 continue 106 107 # The argument test. 108 self.assertRaises(RelaxBoolError, self.state.save_state, state='a', force=data[1])
109 110
112 """Test the proper failure of the state.save() user function for the compress_type argument.""" 113 114 # Loop over the data types. 115 for data in DATA_TYPES: 116 # Catch the int and bin arguments, and skip them. 117 if data[0] == 'int' or data[0] == 'bin': 118 continue 119 120 # The argument test. 121 self.assertRaises(RelaxIntError, self.state.save_state, state='a', compress_type=data[1])
122