Package test_suite :: Package unit_tests :: Package _lib :: Module test_periodic_table
[hide private]
[frames] | no frames]

Source Code for Module test_suite.unit_tests._lib.test_periodic_table

 1  ############################################################################### 
 2  #                                                                             # 
 3  # Copyright (C) 2014 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 unittest import TestCase 
24   
25  # relax module imports. 
26  from lib.periodic_table import periodic_table 
27   
28   
29 -class Test_periodic_table(TestCase):
30 """Unit tests for the lib.periodic_table module.""" 31 32
33 - def test_get_atomic_mass(self):
34 """Test of the periodic_table.atomic_mass() method.""" 35 36 # Check the proton weight. 37 weight = periodic_table.atomic_mass(id='H') 38 self.assertEqual(weight, 1.007975) 39 40 # Check the 1H weight. 41 weight = periodic_table.atomic_mass(id='1H') 42 self.assertEqual(weight, 1.0078250322) 43 44 # Check the 2H weight. 45 weight = periodic_table.atomic_mass(id='2H') 46 self.assertEqual(weight, 2.0141017781)
47 48
49 - def test_get_atomic_weight(self):
50 """Test of the periodic_table.atomic_weight() method.""" 51 52 # Check the proton weight. 53 weight = periodic_table.atomic_weight(symbol='H') 54 self.assertEqual(weight, 1.007975) 55 56 # Check the helium weight. 57 weight = periodic_table.atomic_weight(symbol='He') 58 self.assertEqual(weight, 4.002602)
59 60
61 - def test_has_element_C(self):
62 """Test of the Periodic_table.has_element() method with the symbol 'C'.""" 63 64 # Check. 65 self.assertTrue(periodic_table.has_element('C'))
66 67
68 - def test_has_element_NI(self):
69 """Test of the Periodic_table.has_element() method with the symbol 'NI'.""" 70 71 # Check. 72 self.assertTrue(periodic_table.has_element('NI'))
73 74
75 - def test_has_element_Ni(self):
76 """Test of the Periodic_table.has_element() method with the symbol 'Ni'.""" 77 78 # Check. 79 self.assertTrue(periodic_table.has_element('Ni'))
80 81
82 - def test_has_element_XYZ(self):
83 """Test of the Periodic_table.has_element() method with the symbol 'XYZ'.""" 84 85 # Check. 86 self.assertTrue(not periodic_table.has_element('XYZ'))
87