Package test_suite :: Package unit_tests :: Package _data :: Module test___init__
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._data.test___init__

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2007-2011 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  import data; ds = data.Relax_data_store() 
28  from test_suite.unit_tests.package_checking import PackageTestCase 
29   
30   
31 -class Empty_container:
32 """An empty data container."""
33 34
35 -class Test___init__(PackageTestCase):
36 """Unit tests for the data.Relax_data_store class.""" 37
38 - def setUp(self):
39 """Set up a complex relax data store.""" 40 41 # Package info. 42 self.package = data 43 self.package_name = 'data' 44 self.package_path = sys.path[0] + sep + 'data' 45 46 # Add an empty data container as a new pipe. 47 ds['empty'] = Empty_container() 48 49 # Add an object to the empty data container. 50 ds['empty'].x = 1 51 52 # Add an object to the data store object. 53 ds.test = 1
54 55
56 - def test_add(self):
57 """Unit test for testing the addition of a new data pipe by the 'add()' method.""" 58 59 # Add a new data pipe. 60 ds.add(pipe_name='new', pipe_type='mf') 61 62 # Test that the new data pipe exists. 63 self.assert_('new' in ds)
64 65
66 - def test_repr(self):
67 """Unit test for the validity of the __repr__() method.""" 68 69 # Test that __repr__() returns a string. 70 self.assert_(type(ds.__repr__()), str)
71 72
73 - def test_reset(self):
74 """Unit test for the __reset__() class method.""" 75 76 # Execute the reset method. 77 ds.__reset__() 78 79 # Test that there are no keys. 80 self.assertEqual(list(ds.keys()), []) 81 82 # Test that the object ds.test is deleted. 83 self.assert_(not hasattr(ds, 'test')) 84 85 # Test that the object methods still exist. 86 self.assert_(hasattr(ds, '__new__')) 87 self.assert_(hasattr(ds, '__repr__')) 88 self.assert_(hasattr(ds, '__reset__')) 89 self.assert_(hasattr(ds, 'add')) 90 91 # Test that the object's initial objects still exist. 92 self.assert_(hasattr(ds, 'current_pipe'))
93