Author: bugman Date: Mon Jan 7 11:40:38 2008 New Revision: 4405 URL: http://svn.gna.org/viewcvs/relax?rev=4405&view=rev Log: Wrote 5 unit tests for the arguments of the minimise.grid_search() user function. Modified: 1.3/test_suite/unit_tests/_prompt/test_minimisation.py Modified: 1.3/test_suite/unit_tests/_prompt/test_minimisation.py URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/unit_tests/_prompt/test_minimisation.py?rev=4405&r1=4404&r2=4405&view=diff ============================================================================== --- 1.3/test_suite/unit_tests/_prompt/test_minimisation.py (original) +++ 1.3/test_suite/unit_tests/_prompt/test_minimisation.py Mon Jan 7 11:40:38 2008 @@ -26,7 +26,7 @@ # relax module imports. from data import Data as relax_data_store from prompt.minimisation import Minimisation -from relax_errors import RelaxIntError +from relax_errors import RelaxBinError, RelaxIntError, RelaxIntListIntError, RelaxListError, RelaxListNumError from test_suite.unit_tests.minimisation_testing_base import Minimisation_base_class # Unit test imports. @@ -52,3 +52,78 @@ # The argument test. self.assertRaises(RelaxIntError, self.minimisation_fns.calc, print_flag=data[1]) + + + def test_grid_search_argfail_lower(self): + """The lower arg test of the minimisation.grid_search() user function.""" + + # Loop over the data types. + for data in DATA_TYPES: + # Catch the None arguments, and skip them. + if data[0] == 'None': + continue + + # Catch the non-number list arguments. + if type(data[1]) == list and (data[0] != 'int list' or data[0] != 'float list' or data[0] != 'number list'): + self.assertRaises(RelaxListNumError, self.minimisation_fns.grid_search, lower=data[1]) + + # All other arguments. + else: + self.assertRaises(RelaxListError, self.minimisation_fns.grid_search, lower=data[1]) + + + def test_grid_search_argfail_upper(self): + """The upper arg test of the minimisation.grid_search() user function.""" + + # Loop over the data types. + for data in DATA_TYPES: + # Catch the None arguments, and skip them. + if data[0] == 'None': + continue + + # Catch the non-number list arguments. + if type(data[1]) == list and (data[0] != 'int list' or data[0] != 'float list' or data[0] != 'number list'): + self.assertRaises(RelaxListNumError, self.minimisation_fns.grid_search, upper=data[1]) + + # All other arguments. + else: + self.assertRaises(RelaxListError, self.minimisation_fns.grid_search, upper=data[1]) + + + def test_grid_search_argfail_inc(self): + """The inc arg test of the minimisation.grid_search() user function.""" + + # Loop over the data types. + for data in DATA_TYPES: + # Catch the bin, int, and interger list arguments, and skip them. + if data[0] == 'bin' or data[0] == 'int' or data[0] == 'int list': + continue + + # The argument test. + self.assertRaises(RelaxIntListIntError, self.minimisation_fns.grid_search, inc=data[1]) + + + def test_grid_search_argfail_constraints(self): + """The constraints arg test of the minimisation.grid_search() user function.""" + + # Loop over the data types. + for data in DATA_TYPES: + # Catch the bin arguments, and skip them. + if data[0] == 'bin': + continue + + # The argument test. + self.assertRaises(RelaxBinError, self.minimisation_fns.grid_search, constraints=data[1]) + + + def test_grid_search_argfail_print_flag(self): + """The print_flag arg test of the minimisation.grid_search() user function.""" + + # Loop over the data types. + for data in DATA_TYPES: + # Catch the int and bin arguments, and skip them. + if data[0] == 'int' or data[0] == 'bin': + continue + + # The argument test. + self.assertRaises(RelaxIntError, self.minimisation_fns.grid_search, print_flag=data[1])