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 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.8.0b1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_fxa_mte-1.8.0b1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest_fxa_mte-1.8.0b1.tar.gz.

File metadata

  • Download URL: pytest_fxa_mte-1.8.0b1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pytest_fxa_mte-1.8.0b1.tar.gz
Algorithm Hash digest
SHA256 c055501a40c71db934f3dbb4a27b80a559d9fccc49a9468246c5c3189725f83b
MD5 40f15e903a91bdf9e43a8de9cf7f072e
BLAKE2b-256 e9fc3d6a1b19ad00e5cadc8e8c8dea3ffafbef2fa9c295de39f362fc353b1796

See more details on using hashes here.

File details

Details for the file pytest_fxa_mte-1.8.0b1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_fxa_mte-1.8.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 b741551179c8bd1d4435c61a389384899cd646a418771ca887f7d53cd5b2525b
MD5 c4af68cadfca0c558429f379fccf083a
BLAKE2b-256 f7ab86d15872531ff60d743376f3901327e3d59f1524238e8125020cf9466980

See more details on using hashes here.

Supported by

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