Package test_suite :: Package unit_tests :: Package _specific_fns :: Package _model_free :: Module test_main
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._specific_fns._model_free.test_main

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2008-2012 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 os import sep 
 24  import sys 
 25   
 26  # relax module imports. 
 27  from data import Relax_data_store; ds = Relax_data_store() 
 28  from generic_fns import pipes, results, structure 
 29  from relax_errors import RelaxError 
 30  from specific_fns.model_free import main 
 31  from status import Status; status = Status() 
 32  from test_suite.unit_tests.base_classes import UnitTestCase 
 33   
 34   
35 -class Test_main(UnitTestCase):
36 """Unit tests for the class methods of specific_fns.model_free.main.Model_free_main.""" 37 38 # Instantiate the class. 39 inst = main.Model_free_main() 40 41
42 - def setUp(self):
43 """Setup some structures for the unit tests.""" 44 45 # Create a model-free data pipe. 46 ds.add(pipe_name='orig', pipe_type='mf')
47 48
49 - def test_duplicate_data1(self):
50 """Test the model-free duplicate_data() method.""" 51 52 # Duplicate the data. 53 self.inst.duplicate_data('orig', 'new', model_info=0)
54 55
56 - def test_duplicate_data2(self):
57 """Test the model-free duplicate_data() method.""" 58 59 # Read a model-free results file. 60 results.read(file='final_results_trunc_1.3_v2', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'OMP') 61 62 # Duplicate the data. 63 self.inst.duplicate_data('orig', 'new', model_info=0)
64 65
66 - def test_duplicate_data3(self):
67 """Test the model-free duplicate_data() method.""" 68 69 # Read a model-free results file. 70 results.read(file='final_results_trunc_1.3_v2', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'OMP') 71 72 # Load a structure. 73 structure.main.read_pdb(file='Ap4Aase_res1-12.pdb', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures', read_model=1, parser='internal') 74 75 # Duplicate the data. 76 self.inst.duplicate_data('orig', 'new', model_info=0) 77 78 # Check the original data. 79 self.assert_(hasattr(pipes.get_pipe('orig'), 'structure')) 80 81 # Check the duplication. 82 self.assert_(hasattr(pipes.get_pipe('new'), 'structure'))
83 84
86 """Test the model-free duplicate_data() method.""" 87 88 # Read a model-free results file. 89 results.read(file='final_results_trunc_1.3_v2', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'OMP') 90 91 # Load a structure. 92 structure.main.read_pdb(file='Ap4Aase_res1-12.pdb', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures', read_model=1, parser='internal') 93 94 # Duplicate the data, model by model. 95 self.inst.duplicate_data('orig', 'new', model_info=0) 96 self.inst.duplicate_data('orig', 'new', model_info=1) 97 self.inst.duplicate_data('orig', 'new', model_info=2) 98 self.inst.duplicate_data('orig', 'new', model_info=3)
99 100
102 """Test the failure of the model-free duplicate_data() method when the structures are not consistent.""" 103 104 # Read a model-free results file. 105 results.read(file='final_results_trunc_1.3_v1', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'model_free'+sep+'OMP') 106 107 # Load a structure. 108 structure.main.read_pdb(file='Ap4Aase_res1-12.pdb', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures', read_model=1, parser='internal') 109 110 # Create a new model-free data pipe. 111 ds.add(pipe_name='new', pipe_type='mf') 112 113 # Load the structure for the second pipe. 114 structure.main.read_pdb(file='Ap4Aase_res1-12.pdb', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'structures', read_model=1, parser='internal') 115 116 # Modify the structure. 117 dp = pipes.get_pipe('new') 118 dp.structure.structural_data[0].mol[0].file_name = 'test' 119 120 # Duplicate the data and catch the error. 121 self.assertRaises(RelaxError, self.inst.duplicate_data, 'orig', 'new', model_info=0)
122