diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8df3ca7f..2119bfad 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,6 +11,10 @@ permissions: jobs: release: + # Releases are cut from the upstream repository only. Without this guard the + # workflow also runs on forks, where semantic-release rewrites the version in + # pyproject.toml, commits to the default branch and attempts a PyPI upload. + if: github.repository == 'appium/python-client' runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 diff --git a/test/unit/webdriver/webdriver_test.py b/test/unit/webdriver/webdriver_test.py index 73966a24..6d771608 100644 --- a/test/unit/webdriver/webdriver_test.py +++ b/test/unit/webdriver/webdriver_test.py @@ -16,7 +16,9 @@ from unittest.mock import patch import httpretty +import pytest import urllib3 +from selenium.common.exceptions import WebDriverException from appium import webdriver from appium.options.android import UiAutomator2Options @@ -512,6 +514,36 @@ def test_get_client_config_and_connection_custom_appium_connection(self): assert command_executor._client_config != client_config assert client_config is None + @httpretty.activate + def test_orientation(self): + driver = android_w3c_driver() + httpretty.register_uri( + httpretty.GET, + appium_command('/session/1234567890/orientation'), + body=json.dumps({'value': 'PORTRAIT'}), + ) + assert driver.orientation == 'PORTRAIT' + + @httpretty.activate + def test_set_orientation(self): + driver = android_w3c_driver() + httpretty.register_uri( + httpretty.POST, + appium_command('/session/1234567890/orientation'), + body=json.dumps({'value': 'LANDSCAPE'}), + ) + driver.orientation = 'LANDSCAPE' + assert get_httpretty_request_body(httpretty.last_request()) == {'orientation': 'LANDSCAPE'} + + driver.orientation = 'portrait' + assert get_httpretty_request_body(httpretty.last_request()) == {'orientation': 'portrait'} + + @httpretty.activate + def test_set_orientation_invalid(self): + driver = android_w3c_driver() + with pytest.raises(WebDriverException, match="You can only set the orientation to 'LANDSCAPE' and 'PORTRAIT'"): + driver.orientation = 'INVALID' + class SubWebDriver(WebDriver): def __init__(self, command_executor, options=None):