def test_run_net_cmd_not_found(self): mock_job = make_mock_job() tj = every().second.do(mock_job) cmd = ['/bin/tuna'] state, res, ret = run_net_cmd(cmd) self.assertFalse(state) self.assertRaises(FileNotFoundError)
def test_run_net_cmd_false(self): mock_job = make_mock_job() tj = every().second.do(mock_job) cmd = ['/bin/false'] state, res, ret = run_net_cmd(cmd) self.assertFalse(state) self.assertEqual(res, b'')
def test_run_net_cmd_up0(self): # expected command result is 'Success' so the return # result is actually <schedule.CancelJob> mock_job = make_mock_job() cmd = get_net_cmds(self.bin_dir, 'fpn0', True) tj = every().second.do(mock_job) result = run_net_cmd(cmd) self.assertIsInstance(result, type) self.assertIn('CancelJob', str(result))
def test_run_net_cmd_down0(self): # expected command result is 'Fail' so the return # result is the output of run_net_cmd() mock_job = make_mock_job() cmd = get_net_cmds(self.bin_dir, 'fpn0', False) tj = every().second.do(mock_job) state, res, ret = run_net_cmd(cmd) self.assertFalse(state) self.assertEqual(res, b'') self.assertEqual(ret, 1)
def test_get_net_cmds_bad_path(self): mock_job = make_mock_job() tj = every().second.do(mock_job) bad_dir = '/tmp/foobar/' cmd = ['/tmp/foo0-down.sh'] self.assertFalse(os.path.isdir(bad_dir)) res = get_net_cmds(bad_dir, 'fpn0', True) # print(cmd) self.assertIsNone(res) state, result, ret = run_net_cmd(cmd) self.assertFalse(state) self.assertRaises(FileNotFoundError)