コード例 #1
0
    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)
コード例 #2
0
    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'')
コード例 #3
0
    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))
コード例 #4
0
    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)
コード例 #5
0
    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)