Package test_suite :: Package unit_tests :: Package _specific_analyses :: Package _model_free :: Module test_api
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._specific_analyses._model_free.test_api

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