Skip to content
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

Tests in browser with SouceLabs+Selenium #2623

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,31 @@ python:
- "2.6"
- "2.7"

env:
global:
- secure: "QJqlXGFBbMBCIJYJky3LXXvuk132O9cUqxAw4WI5kmNgbE8oRdyN9jYPbRKJ2XmWHX2mvDuo7M45IJyvsukYvYJO8jgFGygY5GVhcYt6Id3HMapmZfU+VYvNXKmNJJGSTzU6omYO+9qy7QOL2Kyvzt6+/hmloymPHr3poPR0qpxLobNR7izIrZmkuJ5QRINE+ryScbVgLMsMC+ktiXI79Q9/k7BW0gYOTo60XiAqOk1edHYK7SkJ+OHYR8JQA90u5JwOkwWz3cjcqeJJjp8okW0cjV2s5KEumfxEpj/wXAho6lh6dQfeE7ii2DtrUwWs8qYAVVb9dXfV4bvMTTOqGqPi7HlouU10Ai2OU5tWMmqhWJ99nyHL9jeCxxAs2RnwlLL5X4h2bzabpvouMr5v64Q1Lfz0GpX4fLQD+MUsusNI1GTos1t9VkF/yvVn/Ka58a3+pOd5Do/yKPcD7Cfho4pAkvdtqKpNfbocJtxVky4ECbX26fFVhTPKU6/YF94MmpIXzskMMfzRvOx/PApZtyA7siYCgT3LjDrRWgqfKOd22D+e2rI3G1ufAe1QZx4MQD+baLYPrILgmBWJ62ouBTrw368h7PBOCCXWpjMlIED42fw1kz8qOMzAp6bpB4Zk81NduKTohWo+vX6RRWbv4ESBWTpvmpuoXeBoLPs+o0A="
- secure: "e0zp9XZbgY80LKZINTBLnYjdUON7zkC96vK7PyJXRnmrdyrBkF/kmp+wHAu8I/9frrG0oVVL3Okev5XdTzbCG3HQ52Ys63oa/bjqyQ15GBKD0bogvUQ5+f2TFTbOe+xvMKTA1NLnMxBnX9Ta7zPGh1K36zZtGURQY+l/XqLbOf0MT5ExA1JMwXPSxcgHQwoR5T2KqX65gOExdA/CF11EEKcWc3iIqRitFQkuGSeXKYrwH7IaZQqOc+PkX2rwykWse2dFHlm19oJDxS2uaddtfXu6NOVDDNiw3bN7xsd0bSzKb5N0D1tUZcAIDtv3mOqsSv9Ffs1JgcoHKkDnEsC/0I5qLRmld8cpCwONnp6Kx+RdCZs5h6NxdaXCRT51oB/OriRiDZGRrygJOXMG8Gepkk6ydhrE5UCwKaOqehHRL4m3koWbwTXVKpVGjvimzCXE31/+R5G+DKEc93q54IFxAPHEAcdMFbYfYO12R/cT189hY16SXG6KyNl8ZTMImuEbEACkjHmzY2i8BZoITPi6U7SXHoFqcL7Z7QVO2Tr1a2ZgSRyEHrVqhupu+XG7vSKhG9GCa43R7Om1i6FebzvX2IxIEJiYAdBV7ssR6F+pgBAKe1dXZetCC8bToGSqc4WXCkq5DAJmfEmAy204D7/Y2IuxzyBfGbeFOBvF7k50nuI="

install:
- pip install -r requirements-dev.txt

before_script:
# Creatind dumb config, which allows to run HP, listening on all interfaces
- printf '[General]\nhttp_host=0.0.0.0\n' > config.ini
- python Headphones.py -v -d
- sleep 7 # give Web server some time to bind to sockets, etc

script:
- pep8 headphones
- pyflakes headphones
- nosetests

after_success:
- if [[ $TRAVIS_PYTHON_VERSION == "2.7" ]]; then coveralls; fi

after_failure:
- cat ./logs/headphones.log
- cat /home/travis/sauce-connect.log

addons:
sauce_connect: true
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ pep8==1.7.0
pyflakes==1.1.0
pylint==1.3.1 # pylint 1.4 does not run under python 2.6
pyOpenSSL==0.15.1
selenium==2.53.2
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[nosetests]
verbosity=2
tests=headphones
tests=headphones, test-browser
#rednose=1
ignore-files='^.', '^setup.py$'
#ignore-files='^.', '^setup.py$', '^_'
#exclude-dir=lib

with-coverage=1
cover-branches=1
#nologcapture=1

cover-html=1
cover-html-dir=cover-html
Expand Down
27 changes: 27 additions & 0 deletions test-browser/config_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# import os
# import mock
from unittestcompat import TestCase # , TestArgs
from testenv import DRIVER
# from selenium.webdriver.common.keys import Keys


class ConfigTest(TestCase):

def setUp(self):
self.driver = DRIVER

def test_config_open(self):
""" SELENIUM: open config """
driver = self.driver
driver.get("http://localhost:8181/config")
self.assertIn("Headphones - Settings", driver.title)

def tearDown(self):
self.driver.close()

if __name__ == "__main__":
driver = DRIVER
driver.get("http://localhost:8181/config")
print driver.title
print "expected:", "Headphones - Settings"
driver.close()
42 changes: 42 additions & 0 deletions test-browser/testenv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
import datetime
from selenium import webdriver

DRIVER = None
timestamp_str = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S%z')
tunnel_name = 'custom'

ci_travis = ("TRAVIS" in os.environ) and (os.environ["TRAVIS"] == "true")

use_sauce = ci_travis
use_sauce = True
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could modify : use_sauce = False, then tests will be running in local Firefox, without external connections to SouceLabs. Useful for local testing


caps = {
"browserName": "firefox",
"platform" : "Linux",
"version" : "45.0",
}

caps["recordVideo"] = False
caps["recordScreenshots"] = True
caps["screenResolution"] = "1024x768"

caps["tunnel-identifier"] = tunnel_name
caps["name"] = tunnel_name + '-name-' + timestamp_str
caps["build"] = tunnel_name + '-build-' + timestamp_str
caps["tags"] = tunnel_name + '-tags-' + timestamp_str

if ci_travis:
caps["tunnel-identifier"] = os.environ["TRAVIS_JOB_NUMBER"]
caps["name"] = os.environ["TRAVIS_BRANCH"] + "-" + os.environ["TRAVIS_BUILD_NUMBER"]
caps["build"] = os.environ["TRAVIS_BUILD_NUMBER"]
caps["tags"] = [os.environ["TRAVIS_PYTHON_VERSION"], "CI"]

if use_sauce:
username = os.environ["SAUCE_USERNAME"]
access_key = os.environ["SAUCE_ACCESS_KEY"]

hub_url = "%s:%s@localhost:4445" % (username, access_key)
DRIVER = webdriver.Remote(desired_capabilities=caps, command_executor="http://%s/wd/hub" % hub_url)
else:
DRIVER = webdriver.Firefox()