# Path: teuthology/worker.py
# def sentinel(path):
# def restart():
# def stop():
# def load_config(ctx=None):
# def main(ctx):
# def prep_job(job_config, log_file_path, archive_dir):
# def run_job(job_config, teuth_bin_path, archive_dir, verbose):
# def run_with_watchdog(process, job_config):
# def symlink_worker_log(worker_log_path, archive_dir):


import beanstalkc
import os
from unittest.mock import patch, Mock, MagicMock
from datetime import datetime, timedelta
from teuthology import worker
from teuthology.contextutil import MaxWhileTries
            "job_id": "1",
            "worker_log": "worker_log",
            "archive_path": "archive/path",
            "teuthology_branch": "jewel"
        }
        process = Mock()
        process.poll.return_value = "not None"
        m_proc = Mock()
        m_proc.poll.return_value = "not None"
        m_popen.return_value = m_proc
        worker.run_with_watchdog(process, config)
        m_symlink_log.assert_called_with(config["worker_log"], config["archive_path"])

    @patch("os.path.isdir")
    @patch("teuthology.worker.fetch_teuthology")
    @patch("teuthology.worker.teuth_config")
    @patch("teuthology.worker.fetch_qa_suite")
    def test_prep_job(self, m_fetch_qa_suite,
                      m_teuth_config,
                      m_fetch_teuthology, m_isdir):
        config = dict(
            name="the_name",
            job_id="1",
        )
        archive_dir = '/archive/dir'
        log_file_path = '/worker/log'
        m_fetch_teuthology.return_value = '/teuth/path'
        m_fetch_qa_suite.return_value = '/suite/path'
        m_isdir.return_value = True
        m_teuth_config.teuthology_path = None

# Path: teuthology/worker.py
# def sentinel(path):
# def restart():
# def stop():
# def load_config(ctx=None):
# def main(ctx):
# def prep_job(job_config, log_file_path, archive_dir):
# def run_job(job_config, teuth_bin_path, archive_dir, verbose):
# def run_with_watchdog(process, job_config):
# def symlink_worker_log(worker_log_path, archive_dir):


# Path: teuthology/test/test_worker.py
import beanstalkc
import os
from unittest.mock import patch, Mock, MagicMock
from datetime import datetime, timedelta
from teuthology import worker
from teuthology.contextutil import MaxWhileTries

            "job_id": "1",
            "worker_log": "worker_log",
            "archive_path": "archive/path",
            "teuthology_branch": "jewel"
        }
        process = Mock()
        process.poll.return_value = "not None"
        m_proc = Mock()
        m_proc.poll.return_value = "not None"
        m_popen.return_value = m_proc
        worker.run_with_watchdog(process, config)
        m_symlink_log.assert_called_with(config["worker_log"], config["archive_path"])

    @patch("os.path.isdir")
    @patch("teuthology.worker.fetch_teuthology")
    @patch("teuthology.worker.teuth_config")
    @patch("teuthology.worker.fetch_qa_suite")
    def test_prep_job(self, m_fetch_qa_suite,
                      m_teuth_config,
                      m_fetch_teuthology, m_isdir):
        config = dict(
            name="the_name",
            job_id="1",
        )
        archive_dir = '/archive/dir'
        log_file_path = '/worker/log'
        m_fetch_teuthology.return_value = '/teuth/path'
        m_fetch_qa_suite.return_value = '/suite/path'
        m_isdir.return_value = True
        m_teuth_config.teuthology_path = None

        got_config, teuth_bin_path = worker.prep_job(