mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-10 12:47:04 +00:00
🎯 Fix: 99 % 💥 Break: 1 % 💸 Cost: – ⏱️ Time: – 🛡️ Security: 100 % 🏆 Score: 98 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""Unit tests for :mod:`utils.install.lint.playwright`."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
import unittest.mock as mock
|
|
|
|
from utils.install.lint import playwright as playwright_mod
|
|
|
|
|
|
class TestEnsure(unittest.TestCase):
|
|
def test_a_stale_install_is_refreshed(self) -> None:
|
|
with (
|
|
mock.patch.object(
|
|
playwright_mod,
|
|
"npm_local_missing",
|
|
side_effect=[["@axe-core/playwright"], []],
|
|
),
|
|
mock.patch.object(playwright_mod, "npm_install_local_in_repo") as install,
|
|
):
|
|
playwright_mod.ensure()
|
|
install.assert_called_once()
|
|
|
|
def test_a_complete_install_is_left_alone(self) -> None:
|
|
with (
|
|
mock.patch.object(playwright_mod, "npm_local_missing", return_value=[]),
|
|
mock.patch.object(playwright_mod, "npm_install_local_in_repo") as install,
|
|
):
|
|
playwright_mod.ensure()
|
|
install.assert_not_called()
|
|
|
|
def test_a_package_still_missing_after_the_install_fails_loud(self) -> None:
|
|
with (
|
|
mock.patch.object(
|
|
playwright_mod,
|
|
"npm_local_missing",
|
|
return_value=["@axe-core/playwright"],
|
|
),
|
|
mock.patch.object(playwright_mod, "npm_install_local_in_repo"),
|
|
self.assertRaisesRegex(RuntimeError, "@axe-core/playwright"),
|
|
):
|
|
playwright_mod.ensure()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|