From ae6355c093c910b64597d222268db3ef22b3ff40 Mon Sep 17 00:00:00 2001 From: maxkoryukov Date: Sat, 23 Apr 2016 05:17:52 +0500 Subject: [PATCH 1/5] TEST: fix for saucelab --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 41ad6f255..65f8023d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,5 @@ script: - pep8 headphones - pyflakes headphones - nosetests - after_success: - if [[ $TRAVIS_PYTHON_VERSION == "2.7" ]]; then coveralls; fi From 7d9233bf856d4fe81ebf6f1a907a0d58621b7c20 Mon Sep 17 00:00:00 2001 From: maxkoryukov Date: Sat, 23 Apr 2016 05:23:42 +0500 Subject: [PATCH 2/5] Test in browser with SouceLabs Integration with SouceLabs. Could help to prevent bugs, like a bug with FontAwesome in Safari maxkoryukov/headphones#27 --- .travis.yml | 16 ++++++++++++++ requirements-dev.txt | 1 + setup.cfg | 5 ++++- test-browser/config_test.py | 27 ++++++++++++++++++++++++ test-browser/testenv.py | 42 +++++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 test-browser/config_test.py create mode 100644 test-browser/testenv.py diff --git a/.travis.yml b/.travis.yml index 65f8023d6..2e55c5310 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,12 +14,28 @@ 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: + - 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 diff --git a/requirements-dev.txt b/requirements-dev.txt index 09a50e633..03fd3ac1f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index e47a22ee1..fa12d545e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/test-browser/config_test.py b/test-browser/config_test.py new file mode 100644 index 000000000..22536438e --- /dev/null +++ b/test-browser/config_test.py @@ -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() diff --git a/test-browser/testenv.py b/test-browser/testenv.py new file mode 100644 index 000000000..5c0cf225b --- /dev/null +++ b/test-browser/testenv.py @@ -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 + +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() From 81675ee5bf504fbb0ed3c4df8914f71fa1c37384 Mon Sep 17 00:00:00 2001 From: maxkoryukov Date: Sat, 23 Apr 2016 05:27:57 +0500 Subject: [PATCH 3/5] Restore .travis.yml Line break returned --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2e55c5310..7c4caf1b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,7 @@ script: - pep8 headphones - pyflakes headphones - nosetests + after_success: - if [[ $TRAVIS_PYTHON_VERSION == "2.7" ]]; then coveralls; fi From c35427e5becf6b5d65d7c8fc99134baef5d3514f Mon Sep 17 00:00:00 2001 From: maxkoryukov Date: Sat, 23 Apr 2016 06:36:48 +0500 Subject: [PATCH 4/5] BUG: Fixed bug with non-listening Headphones on Travis CI Running HP out of the box on Travis cause the HP does not listen for incoming requests (it was binded to localhost). Fixed by creating empty `config.ini` with `http_host` setting --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7c4caf1b6..da2b76167 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,8 @@ 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 From c14f40557127cc2db9af22d8ec7e402e9b27dab7 Mon Sep 17 00:00:00 2001 From: maxkoryukov Date: Sat, 23 Apr 2016 18:10:12 +0500 Subject: [PATCH 5/5] FIX: correct closing SauceLabs browser --- test-browser/config_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test-browser/config_test.py b/test-browser/config_test.py index 22536438e..8c862e906 100644 --- a/test-browser/config_test.py +++ b/test-browser/config_test.py @@ -18,6 +18,7 @@ def test_config_open(self): def tearDown(self): self.driver.close() + self.driver.quit() if __name__ == "__main__": driver = DRIVER