Пример #1
0
 def test_module_load_error_module_returns_nonetype(self):
     """
     This tests a failure when the `module()` function returns a NoneType
     object (i.e., like what happens with LMOD)
     """
     with patch('subprocess.Popen', side_effect=mock_popen_status_error_return_nonetype):
         with self.assertRaises(TypeError):
             ModuleHelper.module("load", "gcc/4.8.4")
Пример #2
0
 def test_module_load_error_exception(self):
     """
     This tests the execution path in ModuleHelper in which the exec() command would
     throw an exception.
     In the Module call, we execute `modulehelper` so that it generates a list of
     Python commands. If one of them throws an exception we catch it, print a log message,
     and re-raise a BaseException.
     """
     with patch('subprocess.Popen', side_effect=mock_popen_stdout_throws_on_exec):
         with self.assertRaises(BaseException):
             ModuleHelper.module("load", "gcc/4.8.4")
Пример #3
0
 def test_module_load_error_no_modulecmd(self):
     with patch('distutils.spawn.find_executable',
                side_effect=Exception("mock side-effect error")):
         with patch('subprocess.Popen',
                    side_effect=mock_popen_status_mlstatus_error):
             r = ModuleHelper.module("load", "sems-gcc/4.8.4")
     print("result = {}".format(r))
     self.assertEqual(1, r)
Пример #4
0
 def test_module_load_args_as_list(self):
     """
     The `module()` function can take arguments in as a list.
     This tests that module works when the parameter is a list of arguments.
     """
     with patch('subprocess.Popen', side_effect=mock_popen_status_ok):
         r = ModuleHelper.module( [ "unload", "sems-gcc/4.8.4" ] )
     print("result = {}".format(r))
     self.assertEqual(0, r)
Пример #5
0
 def test_module_load_error_by_mlstatus(self):
     with patch('subprocess.Popen', side_effect=mock_popen_status_error_mlstatus):
         r = ModuleHelper.module("load", "sems-gcc/4.8.4")
     print("result = {}".format(r))
     self.assertEqual(1, r)
Пример #6
0
 def test_module_unload_status_ok(self):
     with patch('subprocess.Popen', side_effect=mock_popen_status_ok):
         r = ModuleHelper.module("unload", "sems-gcc/4.8.4")
     print("result = {}".format(r))
     self.assertEqual(0, r)
Пример #7
0
 def test_module_swap_status_ok(self, arg_popen):
     r = ModuleHelper.module("swap", "sems-gcc/4.8.4", "sems-gcc/7.3.0")
     print("result = {}".format(r))
     self.assertEqual(0, r)
Пример #8
0
 def test_module_load_status_error(self, arg_popen):
     r = ModuleHelper.module("load", "sems-gcc/4.8.4")
     print("result = {}".format(r))
     self.assertEqual(1, r)