Skip to content

Commit 99525af

Browse files
committed
[py]: add safari service tests
1 parent 5d3414d commit 99525af

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
import os
19+
import pytest
20+
21+
from selenium.webdriver.safari.service import Service
22+
23+
@pytest.fixture
24+
def service():
25+
return Service()
26+
27+
@pytest.mark.usefixtures("service")
28+
class TestSafariDriverService:
29+
service_path = "/path/to/safaridriver"
30+
31+
@pytest.fixture(autouse=True)
32+
def setup_and_teardown(self):
33+
os.environ["SE_SAFARIDRIVER"] = self.service_path
34+
yield
35+
os.environ.pop("SE_SAFARIDRIVER", None)
36+
37+
def test_uses_path_from_env_variable(self, service):
38+
assert "safaridriver" in service.path
39+
40+
def test_updates_path_after_setting_env_variable(self, service):
41+
new_path = "/foo/bar"
42+
os.environ["SE_SAFARIDRIVER"] = new_path
43+
service.executable_path = self.service_path # Simulating the update
44+
45+
assert "safaridriver" in service.executable_path
46+
47+
def test_enable_logging():
48+
enable_logging = True
49+
service = Service(enable_logging=enable_logging)
50+
assert '--diagnose' in service.service_args
51+
52+
def test_service_url():
53+
service = Service(port=1313)
54+
assert service.service_url == "http://localhost:1313"

0 commit comments

Comments
 (0)