pytest plugin for Firefox Accounts
Project description
pytest-fxa
==========
pytest-fxa is a plugin for pytest_ that provides test accounts for
`Firefox Accounts`_.
.. image:: https://img.shields.io/badge/license-MPL%202.0-blue.svg
:target: https://github.com/davehunt/pytest-fxa/blob/master/LICENSE
:alt: License
.. image:: https://img.shields.io/pypi/v/pytest-fxa.svg
:target: https://pypi.python.org/pypi/pytest-fxa/
:alt: PyPI
.. image:: https://img.shields.io/travis/davehunt/pytest-fxa.svg
:target: https://travis-ci.org/davehunt/pytest-fxa/
:alt: Travis
.. image:: https://img.shields.io/github/issues-raw/davehunt/pytest-fxa.svg
:target: https://github.com/davehunt/pytest-fxa/issues
:alt: Issues
.. image:: https://pyup.io/repos/github/davehunt/pytest-fxa/shield.svg
:target: https://pyup.io/repos/github/davehunt/pytest-fxa
:alt: Updates
.. image:: https://pyup.io/repos/github/davehunt/pytest-fxa/python-3-shield.svg
:target: https://pyup.io/repos/github/davehunt/pytest-fxa/
:alt: 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:
.. code-block:: bash
$ 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:
.. code-block:: python
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'.
Alternatively, you can override the ``fxa_urls`` fixture to specify the URL for
you environment:
.. code-block:: python
@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
---------
- `Release Notes`_
- `Issue Tracker`_
- Code_
.. _pytest: http://www.python.org/
.. _Firefox Accounts: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/Firefox_Accounts
.. _Release Notes: http://github.com/davehunt/pytest-fxa/blob/master/CHANGES.rst
.. _Issue Tracker: http://github.com/davehunt/pytest-fxa/issues
.. _Code: http://github.com/davehunt/pytest-fxa
==========
pytest-fxa is a plugin for pytest_ that provides test accounts for
`Firefox Accounts`_.
.. image:: https://img.shields.io/badge/license-MPL%202.0-blue.svg
:target: https://github.com/davehunt/pytest-fxa/blob/master/LICENSE
:alt: License
.. image:: https://img.shields.io/pypi/v/pytest-fxa.svg
:target: https://pypi.python.org/pypi/pytest-fxa/
:alt: PyPI
.. image:: https://img.shields.io/travis/davehunt/pytest-fxa.svg
:target: https://travis-ci.org/davehunt/pytest-fxa/
:alt: Travis
.. image:: https://img.shields.io/github/issues-raw/davehunt/pytest-fxa.svg
:target: https://github.com/davehunt/pytest-fxa/issues
:alt: Issues
.. image:: https://pyup.io/repos/github/davehunt/pytest-fxa/shield.svg
:target: https://pyup.io/repos/github/davehunt/pytest-fxa
:alt: Updates
.. image:: https://pyup.io/repos/github/davehunt/pytest-fxa/python-3-shield.svg
:target: https://pyup.io/repos/github/davehunt/pytest-fxa/
:alt: 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:
.. code-block:: bash
$ 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:
.. code-block:: python
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'.
Alternatively, you can override the ``fxa_urls`` fixture to specify the URL for
you environment:
.. code-block:: python
@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
---------
- `Release Notes`_
- `Issue Tracker`_
- Code_
.. _pytest: http://www.python.org/
.. _Firefox Accounts: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/Firefox_Accounts
.. _Release Notes: http://github.com/davehunt/pytest-fxa/blob/master/CHANGES.rst
.. _Issue Tracker: http://github.com/davehunt/pytest-fxa/issues
.. _Code: http://github.com/davehunt/pytest-fxa
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.0.0.tar.gz
(5.1 kB
view details)
Built Distribution
File details
Details for the file pytest-fxa-1.0.0.tar.gz
.
File metadata
- Download URL: pytest-fxa-1.0.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cf146d6d04aadc2d1ac58bf10102942b41e39186422376933e4cd1f86dc3388 |
|
MD5 | 6277727b073236f3baeef610af9cb9ed |
|
BLAKE2b-256 | a4174ad1b5de0086756e43c18bd2d0d8b8c752dd2acb3158c550b93e8db8dc27 |
File details
Details for the file pytest_fxa-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_fxa-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2b0c5e45b0e20aee55d370b1f3544d545fede1d4fcfb633717f544a065f26a8 |
|
MD5 | 1239d717f7bc8cf90a876c87ea46b3ef |
|
BLAKE2b-256 | 8853c936f8d1496b510c15a190bb5d11913003c09a95fb6be7d6a8a919f79293 |