From 4d44616f84e36e9a367ffa6d97c7f97296e59832 Mon Sep 17 00:00:00 2001 From: Dor-bl <59066376+Dor-bl@users.noreply.github.com> Date: Sun, 11 Oct 2026 08:00:57 +0000 Subject: [PATCH 1/4] test: add unit tests for get_npm function Adds unit tests in test/unit/webdriver/appium_service_test.py for get_npm covering POSIX, Windows, and executable not found cases. --- test/unit/webdriver/appium_service_test.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/unit/webdriver/appium_service_test.py b/test/unit/webdriver/appium_service_test.py index d0826c8f..7a166c70 100644 --- a/test/unit/webdriver/appium_service_test.py +++ b/test/unit/webdriver/appium_service_test.py @@ -53,3 +53,20 @@ def advance_time(seconds): assert service.is_listening is expected_result assert clock.perf_counter.return_value == expected_elapsed assert connection.request.call_args_list == [call('HEAD', 'http://127.0.0.1:4723/status')] * expected_requests + + +class TestGetNpm: + def test_get_npm_success_posix(self, monkeypatch): + monkeypatch.setattr(appium_service.sys, 'platform', 'darwin') + monkeypatch.setattr(appium_service, 'find_executable', lambda executable: f'/usr/local/bin/{executable}') + assert appium_service.get_npm() == '/usr/local/bin/npm' + + def test_get_npm_success_win32(self, monkeypatch): + monkeypatch.setattr(appium_service.sys, 'platform', 'win32') + monkeypatch.setattr(appium_service, 'find_executable', lambda executable: f'C:\\Program Files\\nodejs\\{executable}') + assert appium_service.get_npm() == 'C:\\Program Files\\nodejs\\npm.cmd' + + def test_get_npm_not_found_raises_error(self, monkeypatch): + monkeypatch.setattr(appium_service, 'find_executable', lambda executable: None) + with pytest.raises(appium_service.AppiumServiceError, match='Node Package Manager executable cannot be found'): + appium_service.get_npm() From 7fd3898bdc67d602e7531cfdee70dd7aa185c55a Mon Sep 17 00:00:00 2001 From: Dor-bl <59066376+Dor-bl@users.noreply.github.com> Date: Sun, 11 Oct 2026 08:51:41 +0000 Subject: [PATCH 2/4] test: add unit tests for get_npm function Adds unit tests in test/unit/webdriver/appium_service_test.py for get_npm covering POSIX, Windows, and executable not found cases. From 741f14bd9240eef3d04aa545adac3a391254fca7 Mon Sep 17 00:00:00 2001 From: Dor-bl <59066376+Dor-bl@users.noreply.github.com> Date: Sun, 11 Oct 2026 09:35:08 +0000 Subject: [PATCH 3/4] test: add unit tests for get_npm function Adds unit tests in test/unit/webdriver/appium_service_test.py for get_npm covering POSIX, Windows, and executable not found cases. From 6a26093561a1190183fa628e581948087f8b84ff Mon Sep 17 00:00:00 2001 From: Dor-bl <59066376+Dor-bl@users.noreply.github.com> Date: Sun, 11 Oct 2026 10:05:13 +0000 Subject: [PATCH 4/4] test: add unit tests for get_npm function Adds unit tests in test/unit/webdriver/appium_service_test.py for get_npm covering POSIX, Windows, and executable not found cases.