Skip to content

Unit tests don't mock the network requests #233

@peterbe

Description

@peterbe

If you switch off your WiFi and run the whole test suite this happens:

Results (11.58s):
     154 passed
      38 failed
         - tests/test_views.py:390 test_nightly_archive[pyloop]
         - tests/test_views.py:399 test_release_archive[pyloop]
         - tests/test_views.py:409 test_candidate_archive[pyloop]
         - tests/test_views.py:420 test_candidate_archive_build[pyloop]
         - tests/test_views.py:431 test_beta_archive[pyloop]
         - tests/test_views.py:441 test_devedition_archive[pyloop]
         - tests/test_views.py:451 test_esr_archive[pyloop]
         - tests/test_views.py:461 test_release_partner_repacks[pyloop]
         - tests/test_views.py:470 test_candidate_partner_repacks_build[pyloop]
         - tests/test_views.py:479 test_candidate_partner_repacks[pyloop]
         - tests/test_views.py:488 test_beta_partner_repacks[pyloop]
         - tests/test_views.py:497 test_release_balrog_rules[pyloop]
         - tests/test_views.py:505 test_release_buildhub[pyloop]
         - tests/test_views.py:514 test_candidates_buildhub[pyloop]
         - tests/test_views.py:523 test_candidates_buildhub_build[pyloop]
         - tests/test_views.py:532 test_devedition_buildhub[pyloop]
         - tests/test_views.py:541 test_release_bedrock_release_notes[pyloop]
         - tests/test_views.py:549 test_devedition_bedrock_release_notes[pyloop]
         - tests/test_views.py:557 test_release_bedrock_esr_release_notes[pyloop]
         - tests/test_views.py:565 test_release_bedrock_security_advisories[pyloop]
         - tests/test_views.py:573 test_release_bedrock_download_links[pyloop]
         - tests/test_views.py:582 test_devedition_bedrock_download_links[pyloop]
         - tests/test_views.py:592 test_release_bouncer_download_links[pyloop]
         - tests/test_views.py:602 test_devedition_bouncer_download_links[pyloop]
         - tests/test_views.py:612 test_release_product_details[pyloop]
         - tests/test_views.py:620 test_devedition_product_details[pyloop]
         - tests/test_views.py:649 test_esr_balrog_rules[pyloop]
         - tests/test_views.py:657 test_beta_balrog_rules[pyloop]
         - tests/test_views.py:665 test_devedition_balrog_rules[pyloop]
         - tests/test_views.py:673 test_nightly_balrog_rules[pyloop]
         - tests/test_views.py:681 test_firefox_releases_list[pyloop]
         - tests/test_views.py:688 test_devedition_releases_list[pyloop]
         - tests/test_views.py:704 test_heartbeat[pyloop]
         - tests/test_views.py:741 test_ongoing_versions_view_firefox[pyloop]
         - tests/test_views.py:751 test_ongoing_versions_view_devedition[pyloop]
         - tests/test_views.py:757 test_endpoint_have_got_cache_control_headers[pyloop-/v1/__heartbeat__]
         - tests/test_views.py:777 test_get_buildid_for_version[pyloop]
         - tests/test_views.py:782 test_get_buildid_for_nightly_version[pyloop]

That's because those 38 tests depend on actually going out on the network and going to URLs like https://www.mozilla.org/en-US/firefox/58.0beta/releasenotes/

That means the test suite (at least those ~38 tests) aren't unit tests really. They're end-to-end tests.

I'm not worried about the traffic burden on www.mozilla.org and product-details.mozilla.org etc. I'm worried that soon those URLs will expire and tests will fail and nobody will understand how or why.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions