Skip to content

resolves #299 python: adding support to tunnelOwner/tunnelName #311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ name: Java
on:
push:
branches: [ main ]
paths:
- 'java/**'
pull_request:
branches: [ main ]
paths:
- 'java/**'
workflow_dispatch:

jobs:
Expand Down
32 changes: 26 additions & 6 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,43 @@ name: Python

on:
push:
branches: [ main ]
branches:
- main
paths:
- 'python/**'
pull_request:
branches: [ main ]
branches:
- main
paths:
- 'python/**'

jobs:
build:
tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Sauce Connect
uses: saucelabs/sauce-connect-action@v2
with:
python-version: 3.8
username: ${{ secrets.SAUCE_USERNAME }}
accessKey: ${{ secrets.SAUCE_ACCESS_KEY }}
tunnelName: "sauce-bindings-${{ github.sha }}"
region: us-west
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Test with pytest
env:
SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }}
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
run: |
make python_tests

- name: Sauce Connect cleanup
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: sauce-connect-log
path: ${{ env.SAUCE_CONNECT_DIR_IN_HOST }}/sauce-connect.log
3 changes: 0 additions & 3 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Ruby

on:
Expand Down
2 changes: 2 additions & 0 deletions python/saucebindings/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class Configs:
'custom_data': 'customData',
'public': 'public',
'tunnel_identifier': 'tunnelIdentifier',
'tunnel_name': 'tunnelName',
'tunnel_owner': 'tunnelOwner',
'parent_tunnel': 'parentTunnel'
}

Expand Down
4 changes: 4 additions & 0 deletions python/saucebindings/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'iedriver_version': 'iedriverVersion',
'max_duration': 'maxDuration',
'name': 'name',
# parent_tunnel is deprecated and being replaced with tunnel_owner.
'parent_tunnel': 'parentTunnel',
'prerun': 'prerun',
'priority': 'priority',
Expand All @@ -42,7 +43,10 @@
'selenium_version': 'seleniumVersion',
'tags': 'tags',
'time_zone': 'timeZone',
# tunnel_identifier is deprecated and being replaced with tunnel_name.
'tunnel_identifier': 'tunnelIdentifier',
'tunnel_name': 'tunnelName',
'tunnel_owner': 'tunnelOwner',
'video_upload_on_pass': 'videoUploadOnPass',
'capture_performance': 'capturePerformance'
}
Expand Down
4 changes: 2 additions & 2 deletions python/tests/examples/test_common_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class TestCommonOptions(object):

def test_creates_session(self):
# 1. Create SauceOptions instance with common w3c options
sauceOptions = SauceOptions.firefox(browserVersion='73.0',
platformName='Windows 8',
sauceOptions = SauceOptions.firefox(browserVersion='128',
platformName='Windows 11',
unhandledPromptBehavior="ignore")

# 2. Create Session object with SauceOptions object instance
Expand Down
26 changes: 26 additions & 0 deletions python/tests/examples/test_sauce_tunnel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

from saucebindings.options import SauceOptions
from saucebindings.session import SauceSession


class TestSauceOptions(object):

def test_creates_session(self):
# 1. Create a SauceOptions instance using tunnelName of a tunnel started earlier
tunnel_name = "sauce-bindings-{}".format(os.environ.get('GITHUB_SHA') or "test")
sauceOptions = SauceOptions.chrome(extendedDebugging=True,
idleTimeout=45,
tunnelName=tunnel_name)

# 2. Create Session object with SauceOptions object instance
session = SauceSession(sauceOptions)

# 3. Start Session to get the Driver
driver = session.start()

# 4. Use the driver in your tests just like normal
driver.get('https://www.saucedemo.com/')

# 5. Stop the Session with whether the test passed or failed
session.stop(True)
14 changes: 14 additions & 0 deletions python/tests/unit/test_chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,20 @@ def test_accepts_sauce_values_with_dict(self):
assert sauce.tunnel_identifier == 'foobar'
assert sauce.video_upload_on_pass is False

def test_accepts_tunnel(self):
options = {'build': 'bar',
'idleTimeout': 3,
'name': 'foo',
'tunnelOwner': 'bar',
'tunnelName': 'foobar'}

sauce = SauceOptions.chrome(**options)

assert sauce.build == 'bar'
assert sauce.name == 'foo'
assert sauce.tunnel_owner == 'bar'
assert sauce.tunnel_name == 'foobar'

def test_accepts_sauce_values_as_params(self):
custom_data = {'foo': 'foo',
'bar': 'bar'}
Expand Down
14 changes: 14 additions & 0 deletions python/tests/unit/test_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,20 @@ def test_sauce_options(self):
assert options.tunnel_identifier == 'tunnelname'
assert options.video_upload_on_pass is False

def test_accepts_tunnel(self):
options = {'build': 'bar',
'idleTimeout': 3,
'name': 'foo',
'tunnelOwner': 'bar',
'tunnelName': 'foobar'}

sauce = SauceOptions.edge(**options)

assert sauce.build == 'bar'
assert sauce.name == 'foo'
assert sauce.tunnel_owner == 'bar'
assert sauce.tunnel_name == 'foobar'

def test_setting_browser_name(self):
options = SauceOptions.edge()

Expand Down
16 changes: 15 additions & 1 deletion python/tests/unit/test_firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def test_setting_capabilities(self):
assert options.build == 'Sample Build Name'
assert options.command_timeout == 2
assert options.custom_data == custom_data
assert options.extended_debugging == True
assert options.extended_debugging is True
assert options.idle_timeout == 3
assert options.geckodriver_version == '0.23'
assert options.max_duration == 300
Expand Down Expand Up @@ -487,3 +487,17 @@ def test_capabilities_for_selenium(self):
}

assert options.to_capabilities() == expected_capabilities

def test_accepts_tunnel(self):
options = {'build': 'bar',
'idleTimeout': 3,
'name': 'foo',
'tunnelOwner': 'bar',
'tunnelName': 'foobar'}

sauce = SauceOptions.firefox(**options)

assert sauce.build == 'bar'
assert sauce.name == 'foo'
assert sauce.tunnel_owner == 'bar'
assert sauce.tunnel_name == 'foobar'