Tests use obsolete modules and do online operations

Open
#68 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start with fxa/tests/utils.py, fxa/tests/test_core.py, fxa/tests/mock_utilities.py, and fxa/tests/test_requests_auth_plugin.py, then inspect the existing test command and dependency imports. Done means tests no longer require obsolete modules unnecessarily, Python 3 imports work, online tests can be excluded, and the suite runs through the chosen test command without those failures.

Written by the indexing model from the issue text.

Description

help wanted waffle:backlog

I am trying to update and run tests on openSUSE and following things are bit pita:

unittest2 are slowly phased out also they are only imported on py2.6 based on fxa/tests/utils.py thus there is no reason to import/require it every time (those requires should be limited every time, ie to pull in the unittest2 it should be done like unittest2;python_version<"2.7"'

Instead of nose executor it is good idea to use working python setup.py test or switch to pytest (simple swap from nose should be mostly enough).

Grequests should be replaced by py3 compatible requests-threads or requests-futures in test_monkey_patch_for_gevent.

For the online tests they should be skipped ie if you switch to pytest you can use @pytest.mark.online and we can later use pytest -m 'not online' for following tests:

[    3s] fxa/tests/test_core.py::TestCoreClient::test_account_creation_with_key_fetch FAILED [  5%]
[    3s] fxa/tests/test_core.py::TestCoreClient::test_account_login FAILED        [  6%]
[    4s] fxa/tests/test_core.py::TestCoreClient::test_email_code_verification FAILED [  7%]
[    4s] fxa/tests/test_core.py::TestCoreClient::test_forgot_password_flow FAILED [  8%]
[    4s] fxa/tests/test_core.py::TestCoreClient::test_get_random_bytes FAILED     [  9%]
[    4s] fxa/tests/test_core.py::TestCoreClient::test_resend_verify_code FAILED   [ 10%]
[    4s] fxa/tests/test_core.py::TestCoreClient::test_send_unblock_code FAILED    [ 11%]
[    4s] fxa/tests/test_core.py::TestCoreClientSession::test_change_password FAILED [ 12%]
[    4s] fxa/tests/test_core.py::TestCoreClientSession::test_email_status FAILED  [ 13%]
[    4s] fxa/tests/test_core.py::TestCoreClientSession::test_get_identity_assertion FAILED [ 14%]
[    4s] fxa/tests/test_core.py::TestCoreClientSession::test_get_identity_assertion_accepts_service FAILED [ 15%]
[    4s] fxa/tests/test_core.py::TestCoreClientSession::test_get_identity_assertion_handles_duration FAILED [ 16%]
[    4s] fxa/tests/test_core.py::TestCoreClientSession::test_get_random_bytes FAILED [ 16%]
[    4s] fxa/tests/test_core.py::TestCoreClientSession::test_session_status FAILED [ 17%]
[    4s] fxa/tests/test_core.py::TestCoreClientSession::test_sign_certificate FAILED [ 18%]
[    4s] fxa/tests/test_core.py::TestCoreClientSession::test_sign_certificate_handles_duration FAILED [ 19%]
[    4s] fxa/tests/test_core.py::TestCoreClientSession::test_totp FAILED          [ 20%]

You should not import mock on python3 as there it is regular part of the unittest:

[    4s] fxa/tests/test_requests_auth_plugin.py:5: in <module>
[    4s]     from fxa.tests.mock_utilities import (
[    4s] fxa/tests/mock_utilities.py:1: in <module>
[    4s]     import mock
[    4s] E   ModuleNotFoundError: No module named 'mock'

In some parts of the tests you already check for it but here it is hardcoded.

Dominant language
Python
Stars
36
Forks
22
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from mozilla/PyFxA

All issues in mozilla/PyFxA

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.