Skip to content

Commit

Permalink
fixup! fixup! fixup! tests: add git_repo to landings tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shtrom committed Jan 9, 2025
1 parent de30640 commit 2d3451f
Showing 1 changed file with 101 additions and 21 deletions.
122 changes: 101 additions & 21 deletions src/lando/api/tests/test_landings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 2d3451f

Please sign in to comment.