Bug 1470659 - Parametrize capabilities tests. r=whimboo
authorAndreas Tolfsen <ato@sny.no>
Sat, 21 Jul 2018 18:36:50 +0100
changeset 429705 b5d9ec944fe0e33bdea383a1f0114ada1dcabdc3
parent 429704 0ad9872c27e07e5f9dbbb62ec41e5be180e98f05
child 429706 b04c9a64cd61394b559e4abaa6c7c490330db8f3
push id34372
push usernerli@mozilla.com
push dateThu, 02 Aug 2018 08:55:28 +0000
treeherdermozilla-central@bd79b07f57a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1470659
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1470659 - Parametrize capabilities tests. r=whimboo To be able to ignore tests for individual capabilities we need to parametrize these tests. geckodriver now supports setWindowRect, but fails the proxy capability test because it is for some reason not propagated back.
testing/web-platform/meta/webdriver/tests/new_session/response.py.ini
testing/web-platform/tests/webdriver/tests/new_session/response.py
--- a/testing/web-platform/meta/webdriver/tests/new_session/response.py.ini
+++ b/testing/web-platform/meta/webdriver/tests/new_session/response.py.ini
@@ -1,7 +1,6 @@
 [response.py]
-  [test_capabilites]
+  [test_capability_type\[proxy-dict\]]
     expected: FAIL
 
-  [test_data]
+  [test_capability_default_value\[proxy-default_value2\]]
     expected: FAIL
-
--- a/testing/web-platform/tests/webdriver/tests/new_session/response.py
+++ b/testing/web-platform/tests/webdriver/tests/new_session/response.py
@@ -1,53 +1,43 @@
-# META: timeout=long
+import uuid
 
-import uuid
+import pytest
 
 from tests.support.asserts import assert_success
 
 
 def test_sessionid(new_session, add_browser_capabilities):
     response, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilities({})}})
     value = assert_success(response)
     assert isinstance(value["sessionId"], basestring)
     uuid.UUID(hex=value["sessionId"])
 
 
-def test_capabilites(new_session, add_browser_capabilities):
-    response, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilities({})}})
-    value = assert_success(response)
-    assert isinstance(value["capabilities"], dict)
-
-    all_capabilities = set(value["capabilities"].keys())
-    expected_capabilities = {
-        "browserName",
-        "browserVersion",
-        "platformName",
-        "acceptInsecureCerts",
-        "setWindowRect",
-        "timeouts",
-        "proxy",
-        "pageLoadStrategy",
-    }
-
-    assert expected_capabilities.issubset(all_capabilities), (
-        "{0} cannot be found in {1}".format(
-            list(expected_capabilities - all_capabilities), all_capabilities))
+@pytest.mark.parametrize("capability, type", [
+    ("browserName", basestring),
+    ("browserVersion", basestring),
+    ("platformName", basestring),
+    ("acceptInsecureCerts", bool),
+    ("pageLoadStrategy", basestring),
+    ("proxy", dict),
+    ("setWindowRect", bool),
+    ("timeouts", dict),
+    ("unhandledPromptBehavior", basestring),
+])
+def test_capability_type(session, capability, type):
+    assert isinstance(session.capabilities, dict)
+    assert capability in session.capabilities
+    assert isinstance(session.capabilities[capability], type)
 
 
-def test_data(new_session, add_browser_capabilities, platform_name):
-    response, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilities({})}})
-    value = assert_success(response)
-
-    assert isinstance(value["capabilities"]["browserName"], basestring)
-    assert isinstance(value["capabilities"]["browserVersion"], basestring)
-    if platform_name:
-        assert value["capabilities"]["platformName"] == platform_name
-    else:
-        assert "platformName" in value["capabilities"]
-    assert value["capabilities"]["acceptInsecureCerts"] is False
-    assert isinstance(value["capabilities"]["setWindowRect"], bool)
-    assert value["capabilities"]["timeouts"]["implicit"] == 0
-    assert value["capabilities"]["timeouts"]["pageLoad"] == 300000
-    assert value["capabilities"]["timeouts"]["script"] == 30000
-    assert value["capabilities"]["proxy"] == {}
-    assert value["capabilities"]["pageLoadStrategy"] == "normal"
+@pytest.mark.parametrize("capability, default_value", [
+    ("acceptInsecureCerts", False),
+    ("pageLoadStrategy", "normal"),
+    ("proxy", {}),
+    ("setWindowRect", True),
+    ("timeouts", {"implicit": 0, "pageLoad": 300000, "script": 30000}),
+    ("unhandledPromptBehavior", "dismiss and notify"),
+])
+def test_capability_default_value(session, capability, default_value):
+    assert isinstance(session.capabilities, dict)
+    assert capability in session.capabilities
+    assert session.capabilities[capability] == default_value