Skip to content

Commit e07f873

Browse files
committed
fix: review that CLOBBER file is in diff in merge day tests
This is something I noticed was missing while reviewing the final form of #1231.
1 parent 3ec2b54 commit e07f873

2 files changed

Lines changed: 45 additions & 5 deletions

File tree

landoscript/tests/conftest.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import datetime
12
import json
23
from pathlib import Path
34
from yarl import URL
@@ -43,6 +44,19 @@ def privkey_file(datadir):
4344
return datadir / "test_private_key.pem"
4445

4546

47+
@pytest.fixture(scope="function")
48+
def patch_date(monkeypatch):
49+
def inner(location, year, month, day):
50+
class mydate(datetime.date):
51+
@classmethod
52+
def today(cls):
53+
return datetime.date(year, month, day)
54+
55+
monkeypatch.setattr(location, "date", mydate)
56+
57+
return inner
58+
59+
4660
def setup_treestatus_response(aioresponses, context, tree="repo_name", status="approval required", has_err=False):
4761
url = f'{context.config["treestatus_url"]}/trees/{tree}'
4862
if has_err:

landoscript/tests/test_merge_day.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pytest_scriptworker_client import get_files_payload
44
from simple_github.client import GITHUB_GRAPHQL_ENDPOINT
55

6+
from landoscript.actions import merge_day
67
from landoscript.script import async_main
78

89
from .conftest import (
@@ -142,6 +143,7 @@
142143
),
143144
)
144145
async def test_success_bump_main(
146+
patch_date,
145147
aioresponses,
146148
github_installation_responses,
147149
context,
@@ -177,7 +179,11 @@ async def test_success_bump_main(
177179
get_files_payload({"CLOBBER": "# Modifying this file will automatically clobber\nMerge day clobber 2025-03-03"}),
178180
)
179181

182+
patch_date(merge_day, 2025, 6, 10)
183+
180184
def assert_func(req):
185+
initial_replacement_values["CLOBBER"] = "Merge day clobber 2025-03-03\n\\No newline at end of file"
186+
expected_replacement_bumps["CLOBBER"] = "Merge day clobber 2025-06-10\n\\No newline at end of file"
181187
assert_merge_response(
182188
context.config["artifact_dir"],
183189
req,
@@ -194,7 +200,7 @@ def assert_func(req):
194200

195201

196202
@pytest.mark.asyncio
197-
async def test_success_bump_esr(aioresponses, github_installation_responses, context):
203+
async def test_success_bump_esr(patch_date, aioresponses, github_installation_responses, context):
198204
merge_info = {
199205
"to_branch": "esr128",
200206
"version_files": [
@@ -238,20 +244,24 @@ async def test_success_bump_esr(aioresponses, github_installation_responses, con
238244
get_files_payload({"CLOBBER": "# Modifying this file will automatically clobber\nMerge day clobber 2025-03-03"}),
239245
)
240246

247+
patch_date(merge_day, 2025, 6, 10)
248+
241249
def assert_func(req):
242250
assert_merge_response(
243251
context.config["artifact_dir"],
244252
req,
245253
expected_actions,
246254
initial_values,
247255
expected_bumps,
256+
{"CLOBBER": "Merge day clobber 2025-03-03\n\\No newline at end of file"},
257+
{"CLOBBER": "Merge day clobber 2025-06-10\n\\No newline at end of file"},
248258
)
249259

250260
await run_test(aioresponses, github_installation_responses, context, payload, ["merge_day"], True, assert_func=assert_func)
251261

252262

253263
@pytest.mark.asyncio
254-
async def test_success_early_to_late_beta(aioresponses, github_installation_responses, context):
264+
async def test_success_early_to_late_beta(patch_date, aioresponses, github_installation_responses, context):
255265
merge_info = {
256266
"to_branch": "beta",
257267
"replacements": [
@@ -285,7 +295,11 @@ async def test_success_early_to_late_beta(aioresponses, github_installation_resp
285295
get_files_payload({"CLOBBER": "# Modifying this file will automatically clobber\nMerge day clobber 2025-03-03"}),
286296
)
287297

298+
patch_date(merge_day, 2025, 6, 10)
299+
288300
def assert_func(req):
301+
initial_replacement_values["CLOBBER"] = "Merge day clobber 2025-03-03\n\\No newline at end of file"
302+
expected_replacement_bumps["CLOBBER"] = "Merge day clobber 2025-06-10\n\\No newline at end of file"
289303
assert_merge_response(
290304
context.config["artifact_dir"],
291305
req,
@@ -300,7 +314,7 @@ def assert_func(req):
300314

301315

302316
@pytest.mark.asyncio
303-
async def test_success_main_to_beta_merge_day(aioresponses, github_installation_responses, context):
317+
async def test_success_main_to_beta_merge_day(patch_date, aioresponses, github_installation_responses, context):
304318
# despite it looking weird, these beta looking versions _are_ the correct
305319
# "before" versions after we've "merged" the main into beta
306320
initial_values = {
@@ -472,6 +486,8 @@ async def test_success_main_to_beta_merge_day(aioresponses, github_installation_
472486
get_files_payload({"CLOBBER": "# Modifying this file will automatically clobber\nMerge day clobber 2025-03-03"}),
473487
)
474488

489+
patch_date(merge_day, 2025, 6, 10)
490+
475491
aioresponses.post(submit_uri, status=202, payload={"job_id": job_id, "status_url": str(status_uri), "message": "foo", "started_at": "2025-03-08T12:25:00Z"})
476492

477493
aioresponses.get(
@@ -487,6 +503,8 @@ async def test_success_main_to_beta_merge_day(aioresponses, github_installation_
487503
context.task = {"payload": payload, "scopes": scopes}
488504
await async_main(context)
489505

506+
initial_replacement_values["CLOBBER"] = "Merge day clobber 2025-03-03\n\\No newline at end of file"
507+
expected_replacement_values["CLOBBER"] = "Merge day clobber 2025-06-10\n\\No newline at end of file"
490508
req = assert_lando_submission_response(aioresponses.requests, submit_uri)
491509
assert_merge_response(
492510
context.config["artifact_dir"],
@@ -514,7 +532,7 @@ async def test_success_main_to_beta_merge_day(aioresponses, github_installation_
514532

515533

516534
@pytest.mark.asyncio
517-
async def test_success_beta_to_release(aioresponses, github_installation_responses, context):
535+
async def test_success_beta_to_release(patch_date, aioresponses, github_installation_responses, context):
518536
merge_info = {
519537
"end_tag": "FIREFOX_RELEASE_{major_version}_END",
520538
"base_tag": "FIREFOX_RELEASE_{major_version}_BASE",
@@ -574,7 +592,11 @@ async def test_success_beta_to_release(aioresponses, github_installation_respons
574592
get_files_payload({"CLOBBER": "# Modifying this file will automatically clobber\nMerge day clobber 2025-03-03"}),
575593
)
576594

595+
patch_date(merge_day, 2025, 6, 10)
596+
577597
def assert_func(req):
598+
initial_replacement_values["CLOBBER"] = "Merge day clobber 2025-03-03\n\\No newline at end of file"
599+
expected_replacement_values["CLOBBER"] = "Merge day clobber 2025-06-10\n\\No newline at end of file"
578600
assert_merge_response(
579601
context.config["artifact_dir"],
580602
req,
@@ -594,7 +616,7 @@ def assert_func(req):
594616

595617

596618
@pytest.mark.asyncio
597-
async def test_success_release_to_esr(aioresponses, github_installation_responses, context):
619+
async def test_success_release_to_esr(patch_date, aioresponses, github_installation_responses, context):
598620
merge_info = {
599621
# yep...we use `BASE` on the `end_tag` for release-to-esr merges
600622
"end_tag": "FIREFOX_ESR_{major_version}_BASE",
@@ -642,7 +664,11 @@ async def test_success_release_to_esr(aioresponses, github_installation_response
642664
get_files_payload({"CLOBBER": "# Modifying this file will automatically clobber\nMerge day clobber 2025-03-03"}),
643665
)
644666

667+
patch_date(merge_day, 2025, 6, 10)
668+
645669
def assert_func(req):
670+
initial_replacement_values["CLOBBER"] = "Merge day clobber 2025-03-03\n\\No newline at end of file"
671+
expected_replacement_bumps["CLOBBER"] = "Merge day clobber 2025-06-10\n\\No newline at end of file"
646672
assert_merge_response(
647673
context.config["artifact_dir"],
648674
req,

0 commit comments

Comments
 (0)