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 https://img.shields.io/badge/code%20style-black-000000.svg Issues Dependabot

Requirements

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

  • Python 2.7, 3.6, 3.7, 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-mte-1.4.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

pytest_fxa_mte-1.4.0-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest-fxa-mte-1.4.0.tar.gz.

File metadata

  • Download URL: pytest-fxa-mte-1.4.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.20 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for pytest-fxa-mte-1.4.0.tar.gz
Algorithm Hash digest
SHA256 2483cd8d427846db530ddd22f62593ecd12c5fb6e50e8a90aa803e2a8128a59d
MD5 2e248b5122d2d6a563c54cd56a52a900
BLAKE2b-256 aa4a7bccbaee42314cd496293643c6d667fad7b2e2558808c18f23ce705e7fba

See more details on using hashes here.

File details

Details for the file pytest_fxa_mte-1.4.0-py2.py3-none-any.whl.

File metadata

  • Download URL: pytest_fxa_mte-1.4.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/1.0.0 urllib3/1.26.20 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for pytest_fxa_mte-1.4.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9e80f41c30d5f2f6d1b92d51cbcca98326262388acd00d0f9d9695cfda6274cb
MD5 14a18c47ca00e9ec5969073bb98034b1
BLAKE2b-256 df9872575ee0bca5486ec7c652a40f0c87bf9ce0b6ccd6c852145ba41a569f85

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