Improve cli tests
This commit is contained in:
parent
d06572744b
commit
f74bfe1821
@ -28,14 +28,10 @@ def pr(
|
|||||||
] = OutputFormat.CONSOLE,
|
] = OutputFormat.CONSOLE,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Get merge status of pull request(s)."""
|
"""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:
|
for pr_ in pr:
|
||||||
status = pr_merge_status(pr_, branches)
|
status = pr_merge_status(pr_, branches)
|
||||||
status.print(format=format)
|
status.print(format=format)
|
||||||
|
if format != OutputFormat.JSON:
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
|
24154
tests/fixtures/compare_nixos-unstable-small_3569a56280e8afba7c10f9171dac71ff882ff1c1.json
vendored
Normal file
24154
tests/fixtures/compare_nixos-unstable-small_3569a56280e8afba7c10f9171dac71ff882ff1c1.json
vendored
Normal file
File diff suppressed because one or more lines are too long
24154
tests/fixtures/compare_nixos-unstable_3569a56280e8afba7c10f9171dac71ff882ff1c1.json
vendored
Normal file
24154
tests/fixtures/compare_nixos-unstable_3569a56280e8afba7c10f9171dac71ff882ff1c1.json
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -43,7 +43,6 @@ class TestCli(unittest.TestCase):
|
|||||||
"title": "wireshark: 4.2.6 -> 4.2.7",
|
"title": "wireshark: 4.2.6 -> 4.2.7",
|
||||||
"merged": True,
|
"merged": True,
|
||||||
"branches": {
|
"branches": {
|
||||||
"master": True,
|
|
||||||
"nixos-unstable-small": True,
|
"nixos-unstable-small": True,
|
||||||
"nixos-unstable": True,
|
"nixos-unstable": True,
|
||||||
"nixos-24.11": False,
|
"nixos-24.11": False,
|
||||||
@ -51,3 +50,34 @@ class TestCli(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
output = json.loads(result.output)
|
output = json.loads(result.output)
|
||||||
self.assertEqual(output, expected)
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user