Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
add command line options
Browse files Browse the repository at this point in the history
  • Loading branch information
bebef1987 committed Oct 10, 2012
1 parent e3f2fbd commit d03483c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
31 changes: 30 additions & 1 deletion conftest.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.


import py import pytest

LOCALES = ['ach', 'af','ak','ar', 'as', 'ast', 'be', 'bg', 'bn-BD', 'bn-IN', 'br', 'bs', 'ca', 'cs', 'csb', 'cy', 'da', 'de', 'el', 'en-GB', LOCALES = ['ach', 'af','ak','ar', 'as', 'ast', 'be', 'bg', 'bn-BD', 'bn-IN', 'br', 'bs', 'ca', 'cs', 'csb', 'cy', 'da', 'de', 'el', 'en-GB',
'en-ZA', 'eo', 'es-AR', 'es-CL', 'es-ES', 'es-MX', 'et', 'eu', 'fa', 'ff', 'fi', 'fr', 'fy-NL', 'ga-IE', 'gd', 'gl', 'gu-IN', 'en-ZA', 'eo', 'es-AR', 'es-CL', 'es-ES', 'es-MX', 'et', 'eu', 'fa', 'ff', 'fi', 'fr', 'fy-NL', 'ga-IE', 'gd', 'gl', 'gu-IN',
'he', 'hi-IN', 'hr', 'hu', 'hy-AM', 'id', 'is', 'it', 'ja', 'kk', 'km', 'kn', 'ko', 'ku', 'lg', 'lij', 'lt', 'lv', 'mai', 'mk', 'he', 'hi-IN', 'hr', 'hu', 'hy-AM', 'id', 'is', 'it', 'ja', 'kk', 'km', 'kn', 'ko', 'ku', 'lg', 'lij', 'lt', 'lv', 'mai', 'mk',
Expand All @@ -19,3 +20,31 @@ def pytest_generate_tests(metafunc):


if 'os' in metafunc.funcargnames: if 'os' in metafunc.funcargnames:
metafunc.parametrize('os', OS) metafunc.parametrize('os', OS)

def pytest_sessionstart(session):
print session.config.option.base_url
if session.config.option.base_url is None:
raise pytest.UsageError('--baseurl must be specified.')

def pytest_addoption(parser):
parser.addoption("--baseurl",
action='store',
dest='base_url',
metavar='url',
help='base url for the application under test.')

parser.addoption("--product",
action='store',
dest='product',
metavar='str',
default='firefox-latest',
help='product under test')

def pytest_funcarg__testsetup(request):
return TestSetup(request)

class TestSetup(object):

def __init__(self, options):
self.base_url = options.config.option.base_url
self.product = options.config.option.product
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
py==1.4.8 py==1.4.8
pytest==2.2.4 pytest==2.2.4
pytest-xdist==1.8 pytest-xdist==1.8
pytest-mozwebqa==1.0
unittestzero unittestzero
requests==0.11.2 requests==0.11.2
beautifulsoup4==4.0.4 beautifulsoup4==4.0.4
Expand Down
16 changes: 7 additions & 9 deletions tests/test_redirects.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from base import Base from base import Base




@pytest.mark.skip_selenium
@pytest.mark.nondestructive
class TestRedirects(Base): class TestRedirects(Base):


@pytest.mark.parametrize('url', ["http://download.allizom.org/", "https://download.allizom.org/"]) @pytest.mark.parametrize('url', ["http://download.allizom.org/", "https://download.allizom.org/"])
Expand All @@ -33,9 +31,9 @@ def test_that_checks_redirect_using_incorrect_query_values(self, url):
Assert.equal(parsed_url.netloc, urlparse(url).netloc, 'Failed on %s \nUsing %s' % (url, param)) Assert.equal(parsed_url.netloc, urlparse(url).netloc, 'Failed on %s \nUsing %s' % (url, param))
Assert.equal(parsed_url.query, urlencode(param), 'Failed on %s \nUsing %s' % (url, param)) Assert.equal(parsed_url.query, urlencode(param), 'Failed on %s \nUsing %s' % (url, param))


def test_that_checks_redirect_using_locales_and_os(self, mozwebqa, lang, os): def test_that_checks_redirect_using_locales_and_os(self, testsetup, lang, os):


url = mozwebqa.base_url url = testsetup.base_url


# Ja locale has a special code for mac # Ja locale has a special code for mac
if lang == 'ja' and os == 'osx': if lang == 'ja' and os == 'osx':
Expand All @@ -54,10 +52,10 @@ def test_that_checks_redirect_using_locales_and_os(self, mozwebqa, lang, os):
Assert.equal(response.status_code, requests.codes.ok, 'Failed on %s \nUsing %s' % (url, param)) Assert.equal(response.status_code, requests.codes.ok, 'Failed on %s \nUsing %s' % (url, param))
Assert.equal(parsed_url.scheme, 'http', 'Failed on %s \nUsing %s' % (url, param)) Assert.equal(parsed_url.scheme, 'http', 'Failed on %s \nUsing %s' % (url, param))


def test_stub_installer_redirect_for_en_us_and_win(self, mozwebqa): def test_stub_installer_redirect_for_en_us_and_win(self, testsetup):
url = mozwebqa.base_url url = testsetup.base_url
param = { param = {
'product': 'firefox-16.0b6', 'product': testsetup.product,
'lang': 'en-US', 'lang': 'en-US',
'os': 'win' 'os': 'win'
} }
Expand All @@ -74,8 +72,8 @@ def test_stub_installer_redirect_for_en_us_and_win(self, mozwebqa):
{'name': 'win', 'folder': 'win32'}, {'name': 'win', 'folder': 'win32'},
{'name': 'osx', 'folder': 'mac'}, {'name': 'osx', 'folder': 'mac'},
{'name': 'linux', 'folder': 'linux-i686'}]) {'name': 'linux', 'folder': 'linux-i686'}])
def test_stub_installer_redirect_for_firefox_latest_alias(self, mozwebqa, operating_system): def test_stub_installer_redirect_for_firefox_latest_alias(self, testsetup, operating_system):
url = mozwebqa.base_url url = testsetup.base_url
param = { param = {
'product': 'firefox-latest', 'product': 'firefox-latest',
'os': operating_system['name'] 'os': operating_system['name']
Expand Down

0 comments on commit d03483c

Please sign in to comment.