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

Source Code for Module test_suite.unit_tests._data_store.test___init__

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