From: Zack Cerza Date: Fri, 20 Jan 2023 20:54:17 +0000 (-0700) Subject: tests: Make sure to patch repo_utils ops X-Git-Tag: 1.2.0~133^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3e6cb25c528b1730f56dadc3396ce3bb6ddf178b;p=teuthology.git tests: Make sure to patch repo_utils ops These tests were hitting the network. Signed-off-by: Zack Cerza --- diff --git a/teuthology/suite/test/test_run_.py b/teuthology/suite/test/test_run_.py index a580c3603c..eefa721f8e 100644 --- a/teuthology/suite/test/test_run_.py +++ b/teuthology/suite/test/test_run_.py @@ -121,11 +121,13 @@ class TestRun(object): assert run.base_config.sha1 == 'ceph_sha1' assert run.base_config.branch == 'ceph_branch' + @patch('teuthology.suite.run.util.git_ls_remote') @patch('requests.head') @patch('teuthology.suite.util.git_branch_exists') @patch('teuthology.suite.util.package_version_for_hash') def test_sha1_nonexistent( self, + m_git_ls_remote, m_package_version_for_hash, m_git_branch_exists, m_requests_head, diff --git a/teuthology/suite/test/test_util.py b/teuthology/suite/test/test_util.py index 2c4e8f4bd5..92ce8c5f62 100644 --- a/teuthology/suite/test/test_util.py +++ b/teuthology/suite/test/test_util.py @@ -8,7 +8,7 @@ from mock import Mock, patch from teuthology.config import config from teuthology.orchestra.opsys import OS from teuthology.suite import util -from teuthology.exceptions import ScheduleFailError +from teuthology.exceptions import BranchNotFoundError, ScheduleFailError REPO_PROJECTS_AND_URLS = [ @@ -67,8 +67,11 @@ class TestUtil(object): assert str(exc.value) == "Scheduling failed: error msg" m_smtp.assert_not_called() + @patch('teuthology.suite.util.fetch_qa_suite') @patch('teuthology.suite.util.smtplib.SMTP') - def test_fetch_repo_no_branch(self, m_smtp): + def test_fetch_repo_no_branch(self, m_smtp, m_fetch_qa_suite): + m_fetch_qa_suite.side_effect = BranchNotFoundError( + "no-branch", "https://github.com/ceph/ceph-ci.git") config.results_email = "example@example.com" with pytest.raises(ScheduleFailError) as exc: util.fetch_repos("no-branch", "test1", dry_run=False) @@ -76,8 +79,11 @@ class TestUtil(object): Branch 'no-branch' not found in repo: https://github.com/ceph/ceph-ci.git!" m_smtp.assert_called() + @patch('teuthology.suite.util.fetch_qa_suite') @patch('teuthology.suite.util.smtplib.SMTP') - def test_fetch_repo_no_branch_dryrun(self, m_smtp): + def test_fetch_repo_no_branch_dryrun(self, m_smtp, m_fetch_qa_suite): + m_fetch_qa_suite.side_effect = BranchNotFoundError( + "no-branch", "https://github.com/ceph/ceph-ci.git") config.results_email = "example@example.com" with pytest.raises(ScheduleFailError) as exc: util.fetch_repos("no-branch", "test1", dry_run=True) diff --git a/teuthology/test/test_worker.py b/teuthology/test/test_worker.py index 877d9903d7..05342b8dc1 100644 --- a/teuthology/test/test_worker.py +++ b/teuthology/test/test_worker.py @@ -178,13 +178,13 @@ class TestWorker(object): worker.run_with_watchdog(process, config) m_symlink_log.assert_called_with(config["worker_log"], config["archive_path"]) + @patch("teuthology.worker.ls_remote") @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): + def test_prep_job(self, m_fetch_qa_suite, m_teuth_config, + m_fetch_teuthology, m_isdir, m_ls_remote): config = dict( name="the_name", job_id="1", @@ -269,6 +269,7 @@ class TestWorker(object): job.bury.assert_called_once_with() job.delete.assert_called_once_with() + @patch("teuthology.worker.ls_remote") @patch("teuthology.worker.report.try_push_job_info") @patch("teuthology.worker.run_job") @patch("beanstalkc.Job", autospec=True) @@ -281,7 +282,7 @@ class TestWorker(object): def test_main_loop_13925( self, m_setup_log_file, m_isdir, m_connect, m_watch_tube, m_fetch_teuthology, m_fetch_qa_suite, m_job, m_run_job, - m_try_push_job_info, + m_try_push_job_info, m_ls_remote, ): m_connection = Mock() jobs = self.build_fake_jobs(