Bug 1470659 - Move platformName test to separate file. r=whimboo
authorAndreas Tolfsen <ato@sny.no>
Sat, 21 Jul 2018 18:33:50 +0100
changeset 825616 a3d141d56e531d882111ccf569c76427091ed088
parent 825615 e99e43a1e400b532ae84c36519da8e0cbc7143ac
child 825617 0ad9872c27e07e5f9dbbb62ec41e5be180e98f05
push id118150
push usermaglione.k@gmail.com
push dateThu, 02 Aug 2018 04:47:08 +0000
reviewerswhimboo
bugs1470659
milestone63.0a1
Bug 1470659 - Move platformName test to separate file. r=whimboo Specific tests for the platformName capability do not belong in the test for the response body structure.
testing/web-platform/tests/webdriver/tests/new_session/conftest.py
testing/web-platform/tests/webdriver/tests/new_session/merge.py
testing/web-platform/tests/webdriver/tests/new_session/page_load_strategy.py
testing/web-platform/tests/webdriver/tests/new_session/platform_name.py
testing/web-platform/tests/webdriver/tests/new_session/response.py
testing/web-platform/tests/webdriver/tests/support/__init__.py
--- a/testing/web-platform/tests/webdriver/tests/new_session/conftest.py
+++ b/testing/web-platform/tests/webdriver/tests/new_session/conftest.py
@@ -1,10 +1,8 @@
-import sys
-
 import pytest
 
 from webdriver.transport import HTTPWireProtocol
 
 
 def product(a, b):
     return [(a, item) for item in b]
 
@@ -61,18 +59,8 @@ def fixture_new_session(request, configu
             custom_session["session"] = response.body["value"]
         return response, custom_session.get("session", None)
 
     yield new_session
 
     if custom_session.get("session") is not None:
         _delete_session(custom_session["session"]["sessionId"])
         custom_session = None
-
-
-@pytest.fixture(scope="session")
-def platform_name():
-    return {
-        "linux2": "linux",
-        "win32": "windows",
-        "cygwin": "windows",
-        "darwin": "mac"
-    }.get(sys.platform)
--- a/testing/web-platform/tests/webdriver/tests/new_session/merge.py
+++ b/testing/web-platform/tests/webdriver/tests/new_session/merge.py
@@ -1,20 +1,20 @@
 # META: timeout=long
 
 import pytest
 
 from tests.support.asserts import assert_error, assert_success
-from conftest import platform_name
+from tests.support import platform_name
 
 
-@pytest.mark.skipif(platform_name() is None, reason="Unsupported platform")
+@pytest.mark.skipif(platform_name is None, reason="Unsupported platform {}".format(platform_name))
 @pytest.mark.parametrize("body", [lambda key, value: {"alwaysMatch": {key: value}},
                                   lambda key, value: {"firstMatch": [{key: value}]}])
-def test_platform_name(new_session, add_browser_capabilities, platform_name, body):
+def test_platform_name(new_session, add_browser_capabilities, body):
     capabilities = body("platformName", platform_name)
     if "alwaysMatch" in capabilities:
         capabilities["alwaysMatch"] = add_browser_capabilities(capabilities["alwaysMatch"])
     else:
         capabilities["firstMatch"][0] = add_browser_capabilities(capabilities["firstMatch"][0])
 
     response, _ = new_session({"capabilities": capabilities})
     value = assert_success(response)
@@ -35,18 +35,18 @@ invalid_merge = [
 def test_merge_invalid(new_session, add_browser_capabilities, key, value):
     response, _ = new_session({"capabilities": {
         "alwaysMatch": add_browser_capabilities({key: value[0]}),
         "firstMatch": [{}, {key: value[1]}],
     }})
     assert_error(response, "invalid argument")
 
 
-@pytest.mark.skipif(platform_name() is None, reason="Unsupported platform")
-def test_merge_platformName(new_session, add_browser_capabilities, platform_name):
+@pytest.mark.skipif(platform_name is None, reason="Unsupported platform {}".format(platform_name))
+def test_merge_platformName(new_session, add_browser_capabilities):
     response, _ = new_session({"capabilities": {
         "alwaysMatch": add_browser_capabilities({"timeouts": {"script": 10}}),
         "firstMatch": [{
             "platformName": platform_name.upper(),
             "pageLoadStrategy": "none",
         }, {
             "platformName": platform_name,
             "pageLoadStrategy": "eager",
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webdriver/tests/new_session/page_load_strategy.py
@@ -0,0 +1,7 @@
+from tests.support.asserts import assert_success
+
+def test_pageLoadStrategy(new_session, add_browser_capabilities):
+    response, _ = new_session({"capabilities": {
+        "alwaysMatch": add_browser_capabilities({"pageLoadStrategy": "eager"})}})
+    value = assert_success(response)
+    assert value["capabilities"]["pageLoadStrategy"] == "eager"
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webdriver/tests/new_session/platform_name.py
@@ -0,0 +1,11 @@
+import pytest
+
+from tests.support import platform_name
+from tests.support.asserts import assert_success
+
+
+@pytest.mark.skip_if(platform_name is None, reason="Unsupported platform {}".format(platform_name))
+def test_corresponds_to_local_system(new_session, add_browser_capabilities):
+    response, _ = new_session({"capabilities": {"alwaysMatch": add_browser_capabilities({})}})
+    value = assert_success(response)
+    assert value["capabilities"]["platformName"] == platform_name
--- a/testing/web-platform/tests/webdriver/tests/new_session/response.py
+++ b/testing/web-platform/tests/webdriver/tests/new_session/response.py
@@ -59,16 +59,8 @@ def test_timeouts(new_session, add_brows
     }})
     value = assert_success(response)
 
     assert value["capabilities"]["timeouts"] == {
         "implicit": 1000,
         "pageLoad": 300000,
         "script": 30000
     }
-
-
-def test_pageLoadStrategy(new_session, add_browser_capabilities, platform_name):
-    response, _ = new_session({"capabilities": {
-        "alwaysMatch": add_browser_capabilities({"pageLoadStrategy": "eager"})}})
-    value = assert_success(response)
-
-    assert value["capabilities"]["pageLoadStrategy"] == "eager"
--- a/testing/web-platform/tests/webdriver/tests/support/__init__.py
+++ b/testing/web-platform/tests/webdriver/tests/support/__init__.py
@@ -1,1 +1,10 @@
+import sys
+
 from merge_dictionaries import merge_dictionaries
+
+platform_name = {
+    "linux2": "linux",
+    "win32": "windows",
+    "cygwin": "windows",
+    "darwin": "mac"
+}.get(sys.platform)