| 1 |
import pytest |
| 2 |
from webdriver.bidi.error import InvalidArgumentException |
| 3 |
|
| 4 |
from bidi.session.new.support.test_data import flat_invalid_data, invalid_extensions |
| 5 |
|
| 6 |
pytestmark = pytest.mark.asyncio |
| 7 |
|
| 8 |
|
| 9 |
@pytest.mark.parametrize("value", [None, True, 1, "{}", []]) |
| 10 |
async def test_params_capabilities_invalid_type(new_session, value): |
| 11 |
with pytest.raises(InvalidArgumentException): |
| 12 |
await new_session(capabilities=value) |
| 13 |
|
| 14 |
|
| 15 |
@pytest.mark.parametrize("value", [True, 1, "{}", []]) |
| 16 |
async def test_params_always_match_invalid_type(new_session, value): |
| 17 |
with pytest.raises(InvalidArgumentException): |
| 18 |
await new_session(capabilities={"alwaysMatch": value}) |
| 19 |
|
| 20 |
|
| 21 |
@pytest.mark.parametrize("value", [True, 1, "{}", {}, []]) |
| 22 |
async def test_params_first_match_invalid_type(new_session, value): |
| 23 |
with pytest.raises(InvalidArgumentException): |
| 24 |
await new_session(capabilities={"firstMatch": value}) |
| 25 |
|
| 26 |
|
| 27 |
@pytest.mark.parametrize("value", [True, 1, "{}", None, []]) |
| 28 |
async def test_params_first_match_item_invalid_type(new_session, value): |
| 29 |
with pytest.raises(InvalidArgumentException): |
| 30 |
await new_session(capabilities={"firstMatch": [value]}) |
| 31 |
|
| 32 |
|
| 33 |
@pytest.mark.parametrize("match_type", ["alwaysMatch", "firstMatch"]) |
| 34 |
@pytest.mark.parametrize("key,value", flat_invalid_data) |
| 35 |
async def test_invalid_value(new_session, match_capabilities, match_type, key, value): |
| 36 |
capabilities = match_capabilities(match_type, key, value) |
| 37 |
|
| 38 |
with pytest.raises(InvalidArgumentException): |
| 39 |
await new_session(capabilities=capabilities) |
| 40 |
|
| 41 |
|
| 42 |
@pytest.mark.parametrize("match_type", ["alwaysMatch", "firstMatch"]) |
| 43 |
@pytest.mark.parametrize("key", invalid_extensions) |
| 44 |
async def test_invalid_extension(new_session, match_capabilities, match_type, key): |
| 45 |
capabilities = match_capabilities(match_type, key, {}) |
| 46 |
|
| 47 |
with pytest.raises(InvalidArgumentException): |
| 48 |
await new_session(capabilities=capabilities) |
| 49 |
|
| 50 |
|
| 51 |
@pytest.mark.parametrize("match_type", ["alwaysMatch", "firstMatch"]) |
| 52 |
async def test_invalid_moz_extension(new_session, match_capabilities, match_type): |
| 53 |
capabilities = match_capabilities(match_type, "moz:someRandomString", {}) |
| 54 |
|
| 55 |
with pytest.raises(InvalidArgumentException): |
| 56 |
await new_session(capabilities=capabilities) |
| 57 |
|
| 58 |
|
| 59 |
async def test_params_with_shadowed_value(new_session): |
| 60 |
with pytest.raises(InvalidArgumentException): |
| 61 |
await new_session( |
| 62 |
capabilities={ |
| 63 |
"firstMatch": [{"acceptInsecureCerts": True}], |
| 64 |
"alwaysMatch": {"acceptInsecureCerts": True}, |
| 65 |
} |
| 66 |
) |