Skip to content

Commit 476096b

Browse files
authored
resolves #299 python: adding support to tunnelOwner/tunnelName (#311)
* python: adding support to tunnelOwner/tunnelName * chore: configure CI paths filter * ci: adding an sc4 tunnel to python tests
1 parent bc8ba41 commit 476096b

File tree

10 files changed

+107
-12
lines changed

10 files changed

+107
-12
lines changed

.github/workflows/java.yml

+4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ name: Java
66
on:
77
push:
88
branches: [ main ]
9+
paths:
10+
- 'java/**'
911
pull_request:
1012
branches: [ main ]
13+
paths:
14+
- 'java/**'
1115
workflow_dispatch:
1216

1317
jobs:

.github/workflows/python.yml

+26-6
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,43 @@ name: Python
55

66
on:
77
push:
8-
branches: [ main ]
8+
branches:
9+
- main
10+
paths:
11+
- 'python/**'
912
pull_request:
10-
branches: [ main ]
13+
branches:
14+
- main
15+
paths:
16+
- 'python/**'
1117

1218
jobs:
13-
build:
19+
tests:
1420
runs-on: ubuntu-latest
1521

1622
steps:
1723
- uses: actions/checkout@v4
18-
- name: Set up Python 3.8
19-
uses: actions/setup-python@v2
24+
- name: Set up Sauce Connect
25+
uses: saucelabs/sauce-connect-action@v2
2026
with:
21-
python-version: 3.8
27+
username: ${{ secrets.SAUCE_USERNAME }}
28+
accessKey: ${{ secrets.SAUCE_ACCESS_KEY }}
29+
tunnelName: "sauce-bindings-${{ github.sha }}"
30+
region: us-west
31+
- name: Set up Python 3.12
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: 3.12
2235
- name: Test with pytest
2336
env:
2437
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
2538
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
2639
run: |
2740
make python_tests
41+
42+
- name: Sauce Connect cleanup
43+
uses: actions/upload-artifact@v3
44+
if: ${{ failure() }}
45+
with:
46+
name: sauce-connect-log
47+
path: ${{ env.SAUCE_CONNECT_DIR_IN_HOST }}/sauce-connect.log

.github/workflows/ruby.yml

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3-
41
name: Ruby
52

63
on:

python/saucebindings/configs.py

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class Configs:
77
'custom_data': 'customData',
88
'public': 'public',
99
'tunnel_identifier': 'tunnelIdentifier',
10+
'tunnel_name': 'tunnelName',
11+
'tunnel_owner': 'tunnelOwner',
1012
'parent_tunnel': 'parentTunnel'
1113
}
1214

python/saucebindings/options.py

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
'iedriver_version': 'iedriverVersion',
3232
'max_duration': 'maxDuration',
3333
'name': 'name',
34+
# parent_tunnel is deprecated and being replaced with tunnel_owner.
3435
'parent_tunnel': 'parentTunnel',
3536
'prerun': 'prerun',
3637
'priority': 'priority',
@@ -42,7 +43,10 @@
4243
'selenium_version': 'seleniumVersion',
4344
'tags': 'tags',
4445
'time_zone': 'timeZone',
46+
# tunnel_identifier is deprecated and being replaced with tunnel_name.
4547
'tunnel_identifier': 'tunnelIdentifier',
48+
'tunnel_name': 'tunnelName',
49+
'tunnel_owner': 'tunnelOwner',
4650
'video_upload_on_pass': 'videoUploadOnPass',
4751
'capture_performance': 'capturePerformance'
4852
}

python/tests/examples/test_common_options.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class TestCommonOptions(object):
66

77
def test_creates_session(self):
88
# 1. Create SauceOptions instance with common w3c options
9-
sauceOptions = SauceOptions.firefox(browserVersion='73.0',
10-
platformName='Windows 8',
9+
sauceOptions = SauceOptions.firefox(browserVersion='128',
10+
platformName='Windows 11',
1111
unhandledPromptBehavior="ignore")
1212

1313
# 2. Create Session object with SauceOptions object instance
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
3+
from saucebindings.options import SauceOptions
4+
from saucebindings.session import SauceSession
5+
6+
7+
class TestSauceOptions(object):
8+
9+
def test_creates_session(self):
10+
# 1. Create a SauceOptions instance using tunnelName of a tunnel started earlier
11+
tunnel_name = "sauce-bindings-{}".format(os.environ.get('GITHUB_SHA') or "test")
12+
sauceOptions = SauceOptions.chrome(extendedDebugging=True,
13+
idleTimeout=45,
14+
tunnelName=tunnel_name)
15+
16+
# 2. Create Session object with SauceOptions object instance
17+
session = SauceSession(sauceOptions)
18+
19+
# 3. Start Session to get the Driver
20+
driver = session.start()
21+
22+
# 4. Use the driver in your tests just like normal
23+
driver.get('https://www.saucedemo.com/')
24+
25+
# 5. Stop the Session with whether the test passed or failed
26+
session.stop(True)

python/tests/unit/test_chrome.py

+14
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,20 @@ def test_accepts_sauce_values_with_dict(self):
117117
assert sauce.tunnel_identifier == 'foobar'
118118
assert sauce.video_upload_on_pass is False
119119

120+
def test_accepts_tunnel(self):
121+
options = {'build': 'bar',
122+
'idleTimeout': 3,
123+
'name': 'foo',
124+
'tunnelOwner': 'bar',
125+
'tunnelName': 'foobar'}
126+
127+
sauce = SauceOptions.chrome(**options)
128+
129+
assert sauce.build == 'bar'
130+
assert sauce.name == 'foo'
131+
assert sauce.tunnel_owner == 'bar'
132+
assert sauce.tunnel_name == 'foobar'
133+
120134
def test_accepts_sauce_values_as_params(self):
121135
custom_data = {'foo': 'foo',
122136
'bar': 'bar'}

python/tests/unit/test_edge.py

+14
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,20 @@ def test_sauce_options(self):
293293
assert options.tunnel_identifier == 'tunnelname'
294294
assert options.video_upload_on_pass is False
295295

296+
def test_accepts_tunnel(self):
297+
options = {'build': 'bar',
298+
'idleTimeout': 3,
299+
'name': 'foo',
300+
'tunnelOwner': 'bar',
301+
'tunnelName': 'foobar'}
302+
303+
sauce = SauceOptions.edge(**options)
304+
305+
assert sauce.build == 'bar'
306+
assert sauce.name == 'foo'
307+
assert sauce.tunnel_owner == 'bar'
308+
assert sauce.tunnel_name == 'foobar'
309+
296310
def test_setting_browser_name(self):
297311
options = SauceOptions.edge()
298312

python/tests/unit/test_firefox.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def test_setting_capabilities(self):
352352
assert options.build == 'Sample Build Name'
353353
assert options.command_timeout == 2
354354
assert options.custom_data == custom_data
355-
assert options.extended_debugging == True
355+
assert options.extended_debugging is True
356356
assert options.idle_timeout == 3
357357
assert options.geckodriver_version == '0.23'
358358
assert options.max_duration == 300
@@ -487,3 +487,17 @@ def test_capabilities_for_selenium(self):
487487
}
488488

489489
assert options.to_capabilities() == expected_capabilities
490+
491+
def test_accepts_tunnel(self):
492+
options = {'build': 'bar',
493+
'idleTimeout': 3,
494+
'name': 'foo',
495+
'tunnelOwner': 'bar',
496+
'tunnelName': 'foobar'}
497+
498+
sauce = SauceOptions.firefox(**options)
499+
500+
assert sauce.build == 'bar'
501+
assert sauce.name == 'foo'
502+
assert sauce.tunnel_owner == 'bar'
503+
assert sauce.tunnel_name == 'foobar'

0 commit comments

Comments
 (0)