Skip to main content

pytest plugin for Firefox Accounts

Project description

pytest-fxa is a plugin for pytest that provides test accounts for Firefox Accounts.

License PyPI Travis Issues Updates Python 3

Requirements

You will need the following prerequisites in order to use pytest-fxa:

  • Python 2.7, 3.6, PyPy, or PyPy3

Installation

To install pytest-fxa:

$ pip install pytest-fxa

Creating a test Firefox Account

To create a Firefox Account for testing, include the fxa_account fixture name in your test method signature. This is a tuple with named properties for the test account’s email and password. The following example shows how this could be used with Selenium to sign into a website that uses Firefox Accounts for authentication:

def test_my_fxa_site(fxa_account, selenium):
    selenium.get('https://example.com/')
    selenium.find_element(By.ID, 'email').send_keys(fxa_account.email)
    selenium.find_element(By.ID, 'password').send_keys(fxa_account.password)
    selenium.find_element(By.ID, 'login').click()

The test account will be automatically destroyed when it’s no longer needed.

Specifying an environment

By default all accounts will be created on the ‘stage’ environment. You can set the FXA_ENV environment variable to target ‘production’ or ‘stable’.

If you need to override the environment for a subset of tests, or run tests against multiple environments, you can use the fxa_env marker:

@pytest.mark.fxa_env('production')
def test_production(fxa_account):
    selenium.get('https://example.com/')
    selenium.find_element(By.ID, 'email').send_keys(fxa_account.email)
    selenium.find_element(By.ID, 'password').send_keys(fxa_account.password)
    selenium.find_element(By.ID, 'login').click()


@pytest.mark.fxa_env('stage', 'stable')
def test_stage(fxa_account):
    selenium.get('https://elpmaxe.com/')
    selenium.find_element(By.ID, 'email').send_keys(fxa_account.email)
    selenium.find_element(By.ID, 'password').send_keys(fxa_account.password)
    selenium.find_element(By.ID, 'login').click()

Alternatively, you can override the fxa_urls fixture for full control of the URLs for your environment:

@pytest.fixture
def fxa_urls():
    return {
        'authentication': 'https://api-accounts.stage.mozaws.net/v1',
        'oauth': 'https://oauth.stage.mozaws.net/v1',
        'content': 'https://accounts.stage.mozaws.net/',
        'profile': 'https://profile.stage.mozaws.net/v1',
        'token': 'https://token.stage.mozaws.net/'}

Resources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-fxa-1.3.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

pytest_fxa-1.3.0-py2.py3-none-any.whl (4.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest-fxa-1.3.0.tar.gz.

File metadata

  • Download URL: pytest-fxa-1.3.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pytest-fxa-1.3.0.tar.gz
Algorithm Hash digest
SHA256 9753faca995135ecae4330a7961e918684f16482afc4eede4bd8a8a8295ac29f
MD5 b5d85d4fe59700fbf163ffd7bb539210
BLAKE2b-256 b0a6783098d437a29aad643f34a79aa2a9593a4f34cfaed62cbdee62ef73afd4

See more details on using hashes here.

File details

Details for the file pytest_fxa-1.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_fxa-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8aa5aca97750ac714300a5013b3a9ddb858eb15b205e4d1d3dfce2746706e4ea
MD5 8537933c38027b0d5100fec8f5d2877c
BLAKE2b-256 e819c0af25358985bb0824df5198938c04407339999281da426440f4f29e1fab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page