def test_main_test12(m_isfile, m_procconf, m_testcon, m_testenv, m_testapp, m_procjob, m_schedprep, m_stagup, m_sub, m_mon, m_del, m_stagdown, m_clean): """Test the disconnect feature with complete jobs.""" m_isfile.return_value = True args = ["longbow", "--job", "testjob", "--disconnect", "--debug"] m_procconf.side_effect = _configload with mock.patch('sys.argv', args): launcher() assert m_procconf.call_count == 1 assert m_testcon.call_count == 1 assert m_testenv.call_count == 1 assert m_testapp.call_count == 1 assert m_procjob.call_count == 1 assert m_schedprep.call_count == 1 assert m_stagup.call_count == 1 assert m_sub.call_count == 1 assert m_mon.call_count == 0 assert m_del.call_count == 0 assert m_stagdown.call_count == 0 assert m_clean.call_count == 0
def test_main_test13(m_isfile, m_procconf, m_testcon, m_testenv, m_testapp, m_procjob, m_schedprep, m_stagup, m_sub, m_mon, m_del, m_stagdown, m_clean): """Test the keyboard interrupt feature with complete jobs.""" m_isfile.return_value = True args = [ "longbow", "--job", "testjob", "--resource", "big-machine", "--debug" ] m_procconf.side_effect = _configload m_mon.side_effect = UpdateExit with mock.patch('sys.argv', args): launcher() assert m_procconf.call_count == 1 assert m_testcon.call_count == 1 assert m_testenv.call_count == 1 assert m_testapp.call_count == 1 assert m_procjob.call_count == 1 assert m_schedprep.call_count == 1 assert m_stagup.call_count == 1 assert m_sub.call_count == 1 assert m_mon.call_count == 1 assert m_del.call_count == 0 assert m_stagdown.call_count == 0 assert m_clean.call_count == 0
def test_main_test2(m_isfile, m_longbowmain): """ Check that the longbow main method gets called, and that the parameters structure is being setup, this is a rudimentary test. """ m_isfile.return_value = True args = [ "longbow", "--jobname", "testjob", "--resource", "big-machine", "--verbose", "pmemd.MPI", "-O", "-i", "ex.in", "-c", "ex.min", "-p", "ex.top", "-o", "ex.out" ] with mock.patch('sys.argv', args): launcher() params = m_longbowmain.call_args[0][1] assert m_longbowmain.call_count == 1 assert params["debug"] is False assert params["disconnect"] is False assert params["executable"] == "pmemd.MPI" assert params["executableargs"] == \ "-O -i ex.in -c ex.min -p ex.top -o ex.out" assert params["hosts"] == os.path.join(os.getcwd(), "hosts.conf") assert params["job"] == "" assert params["jobname"] == "testjob" assert params["log"] == os.path.join(os.getcwd(), "longbow.log") assert params["recover"] == "" assert params["resource"] == "big-machine" assert params["replicates"] == "" assert params["verbose"] is True
def test_main_test8(m_isfile, m_longbowmain, m_recovery): """ Test that exception handling happens properly. """ m_isfile.return_value = True args = [ "longbow", "--jobname", "testjob", "--resource", "big-machine", "--debug" ] with mock.patch('sys.argv', args): with pytest.raises(SystemExit) as err: launcher() assert m_longbowmain.call_count == 0 assert m_recovery.call_count == 0 assert err.type == SystemExit assert err.value.code == 1
def test_main_test3(m_isfile, m_recovery): """ Check that the recovery method gets called, this is a rudimentary test. """ m_isfile.return_value = True args = [ "longbow", "--recover", "recovery.file", "--log", "new-log.file", "--verbose" ] with mock.patch('sys.argv', args): launcher() params = m_recovery.call_args[0][1] assert m_recovery.call_count == 1 assert params == "recovery.file"
def test_main_test5(m_isfile, m_update, m_recovery, m_longbow): """ Check that longbow doesn't launch if too many args are given. """ m_isfile.return_value = True args = [ "longbow", "--recover", "recovery.file", "--update", "update.file", "--log", "new-log.file", "--verbose" ] with mock.patch('sys.argv', args): with pytest.raises(SystemExit) as err: launcher() assert m_longbow.call_count == 0 assert m_recovery.call_count == 0 assert m_update.call_count == 0 assert err.type == SystemExit assert err.value.code == 1
def test_main_test7(m_isfile, m_longbowmain): """ Test that exception handling happens properly. """ m_isfile.return_value = True args = [ "longbow", "--jobname", "testjob", "--resource", "big-machine", "--debug", "pmemd.MPI", "-O", "-i", "ex.in", "-c", "ex.min", "-p", "ex.top", "-o", "ex.out" ] m_longbowmain.side_effect = exceptions.PluginattributeError with mock.patch('sys.argv', args): with pytest.raises(SystemExit) as err: launcher() params = m_longbowmain.call_args[0][1] assert m_longbowmain.call_count == 1 assert params["debug"] is True assert params["disconnect"] is False assert params["executable"] == "pmemd.MPI" assert params["executableargs"] == \ "-O -i ex.in -c ex.min -p ex.top -o ex.out" assert params["hosts"] == os.path.join(os.getcwd(), "hosts.conf") assert params["job"] == "" assert params["jobname"] == "testjob" assert params["log"] == os.path.join(os.getcwd(), "longbow.log") assert params["recover"] == "" assert params["resource"] == "big-machine" assert params["replicates"] == "" assert params["verbose"] is False assert err.type == SystemExit assert err.value.code == 1