Improve cli tests
All checks were successful
test / test (pull_request) Successful in 29s
build / build (pull_request) Successful in 1m16s

This commit is contained in:
Torjus Håkestad 2025-01-06 23:18:25 +01:00
parent d06572744b
commit f74bfe1821
Signed by: torjus
SSH Key Fingerprint: SHA256:KjAds8wHfD2mBYK2H815s/+ABcSdcIHUndwHEdSxml4
4 changed files with 48341 additions and 7 deletions

View File

@ -28,14 +28,10 @@ def pr(
] = OutputFormat.CONSOLE,
) -> None:
"""Get merge status of pull request(s)."""
if isinstance(pr, int):
status = pr_merge_status(pr, branches)
status.print(format=format)
return
for pr_ in pr:
status = pr_merge_status(pr_, branches)
status.print(format=format)
if format != OutputFormat.JSON:
print()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -43,7 +43,6 @@ class TestCli(unittest.TestCase):
"title": "wireshark: 4.2.6 -> 4.2.7",
"merged": True,
"branches": {
"master": True,
"nixos-unstable-small": True,
"nixos-unstable": True,
"nixos-24.11": False,
@ -51,3 +50,34 @@ class TestCli(unittest.TestCase):
}
output = json.loads(result.output)
self.assertEqual(output, expected)
@unittest.mock.patch("requests.get", side_effect=mocked_requests_get)
def test_pr_multiple(self, mock_get):
result = runner.invoke(app, ["pr", "--format", "json", "345583", "345769"])
self.assertEqual(result.exit_code, 0)
expected = [
{
"title": "wireshark: 4.2.6 -> 4.2.7",
"merged": True,
"branches": {
"master": True,
"nixos-unstable-small": True,
"nixos-unstable": True,
"nixos-24.11": False,
},
},
{
"title": "Firefox: 130.0.1 -> 131.0; 128.2.0esr -> 128.3.0esr; 115.15.0esr -> 115.16.0esr",
"merged": True,
"branches": {
"nixos-unstable-small": False,
"nixos-unstable": False,
"nixos-24.11 (#346022)": True,
},
},
]
output = []
for line in result.output.split("\n"):
if len(line) > 0:
output.append(json.loads(line))
self.assertEqual(output, expected)