diff --git a/src/lando/api/tests/test_landings.py b/src/lando/api/tests/test_landings.py index 6f1055e7..b05fb924 100644 --- a/src/lando/api/tests/test_landings.py +++ b/src/lando/api/tests/test_landings.py @@ -306,7 +306,7 @@ def factory(scm_type: str) -> Repo: ) @pytest.mark.django_db def test_integrated_execute_job( - repo_mc: Repo, + repo_mc, treestatusdouble, monkeypatch, create_patch_revision, @@ -345,14 +345,22 @@ def test_integrated_execute_job( ), "Successful landing should trigger Phab repo update." +@pytest.mark.parametrize( + "repo_type", + [ + SCM_TYPE_GIT, + SCM_TYPE_HG, + ], +) @pytest.mark.django_db def test_integrated_execute_job_with_force_push( - hg_repo_mc, + repo_mc, treestatusdouble, monkeypatch, create_patch_revision, + repo_type: str, ): - repo = hg_repo_mc + repo = repo_mc(repo_type) repo.force_push = True treestatusdouble.open_tree(repo.name) scm = repo.scm @@ -383,14 +391,22 @@ def test_integrated_execute_job_with_force_push( assert scm.push.call_args[1] == {"push_target": "", "force_push": True} +@pytest.mark.parametrize( + "repo_type", + [ + SCM_TYPE_GIT, + SCM_TYPE_HG, + ], +) @pytest.mark.django_db def test_integrated_execute_job_with_bookmark( - hg_repo_mc, + repo_mc, treestatusdouble, monkeypatch, create_patch_revision, + repo_type: str, ): - repo = hg_repo_mc + repo = repo_mc(repo_type) repo.push_target = "@" treestatusdouble.open_tree(repo.name) scm = repo.scm @@ -421,14 +437,22 @@ def test_integrated_execute_job_with_bookmark( assert scm.push.call_args[1] == {"push_target": "@", "force_push": False} +@pytest.mark.parametrize( + "repo_type", + [ + SCM_TYPE_GIT, + SCM_TYPE_HG, + ], +) @pytest.mark.django_db def test_no_diff_start_line( - hg_repo_mc, + repo_mc, treestatusdouble, create_patch_revision, caplog, + repo_type: str, ): - repo = hg_repo_mc + repo = repo_mc(repo_type) treestatusdouble.open_tree(repo.name) job_params = { @@ -449,14 +473,22 @@ def test_no_diff_start_line( assert "Patch without a diff start line." in caplog.text +@pytest.mark.parametrize( + "repo_type", + [ + SCM_TYPE_GIT, + SCM_TYPE_HG, + ], +) @pytest.mark.django_db def test_lose_push_race( monkeypatch, - hg_repo_mc, + repo_mc, treestatusdouble, create_patch_revision, + repo_type: str, ): - repo = hg_repo_mc + repo = repo_mc(repo_type) treestatusdouble.open_tree(repo.name) scm = repo.scm @@ -486,15 +518,23 @@ def test_lose_push_race( assert job.status == LandingJobStatus.DEFERRED +@pytest.mark.parametrize( + "repo_type", + [ + SCM_TYPE_GIT, + SCM_TYPE_HG, + ], +) @pytest.mark.django_db def test_failed_landing_job_notification( - hg_repo_mc, + repo_mc, treestatusdouble, monkeypatch, create_patch_revision, + repo_type: str, ): """Ensure that a failed landings triggers a user notification.""" - repo = hg_repo_mc + repo = repo_mc(repo_type) repo.approval_required = True repo.autoformat_enabled = False treestatusdouble.open_tree(repo.name) @@ -587,16 +627,24 @@ def test_landing_worker__extract_error_data(): assert rejects_paths == expected_rejects_paths +@pytest.mark.parametrize( + "repo_type", + [ + SCM_TYPE_GIT, + SCM_TYPE_HG, + ], +) @pytest.mark.django_db def test_format_patch_success_unchanged( - hg_repo_mc, + repo_mc, treestatusdouble, monkeypatch, create_patch_revision, normal_patch, + repo_type: str, ): """Tests automated formatting happy path where formatters made no changes.""" - repo = hg_repo_mc + repo = repo_mc(repo_type) treestatusdouble.open_tree(repo.name) repo.autoformat_enabled = True @@ -633,15 +681,23 @@ def test_format_patch_success_unchanged( ), "Autoformat making no changes should leave `formatted_replacements` empty." +@pytest.mark.parametrize( + "repo_type", + [ + SCM_TYPE_GIT, + SCM_TYPE_HG, + ], +) @pytest.mark.django_db def test_format_single_success_changed( - hg_repo_mc, + repo_mc, treestatusdouble, monkeypatch, create_patch_revision, + repo_type: str, ): """Test formatting a single commit via amending.""" - repo = hg_repo_mc + repo = repo_mc(repo_type) repo.autoformat_enabled = True treestatusdouble.open_tree(repo.name) scm = repo.scm @@ -713,15 +769,23 @@ def test_format_single_success_changed( ), "Autoformat via amending should only land a single commit." +@pytest.mark.parametrize( + "repo_type", + [ + SCM_TYPE_GIT, + SCM_TYPE_HG, + ], +) @pytest.mark.django_db def test_format_stack_success_changed( - hg_repo_mc, + repo_mc, treestatusdouble, monkeypatch, create_patch_revision, + repo_type: str, ): """Test formatting a stack via an autoformat tip commit.""" - repo = hg_repo_mc + repo = repo_mc(repo_type) repo.autoformat_enabled = (True,) treestatusdouble.open_tree(repo.name) scm = repo.scm @@ -778,15 +842,23 @@ def test_format_stack_success_changed( ), "Autoformat commit has incorrect commit message." +@pytest.mark.parametrize( + "repo_type", + [ + SCM_TYPE_GIT, + SCM_TYPE_HG, + ], +) @pytest.mark.django_db def test_format_patch_fail( - hg_repo_mc, + repo_mc, treestatusdouble, monkeypatch, create_patch_revision, + repo_type: str, ): """Tests automated formatting failures before landing.""" - repo = hg_repo_mc + repo = repo_mc(repo_type) repo.autoformat_enabled = True treestatusdouble.open_tree(repo.name) @@ -826,15 +898,23 @@ def test_format_patch_fail( ), "User should be notified their landing was unsuccessful due to autoformat." +@pytest.mark.parametrize( + "repo_type", + [ + SCM_TYPE_GIT, + SCM_TYPE_HG, + ], +) @pytest.mark.django_db def test_format_patch_no_landoini( - hg_repo_mc, + repo_mc, treestatusdouble, monkeypatch, create_patch_revision, + repo_type: str, ): """Tests behaviour of Lando when the `.lando.ini` file is missing.""" - repo = hg_repo_mc + repo = repo_mc(repo_type) repo.autoformat_enabled = True treestatusdouble.open_tree(repo.name)