mozilla / PyFxA

Python library for interacting with the Firefox Accounts ecosystem
Other
31 stars 20 forks source link

Tests use obsolete modules and do online operations #68

Open scarabeusiv opened 5 years ago

scarabeusiv commented 5 years ago

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.

rfk commented 5 years ago

Thanks for the detailed issue, and apologies for not replying sooner. Unfortunately I don't think I will have time to work on any of these suggestions in the near future, but I would be happy to review contributions addressing any or all of these issues.