Page MenuHomeSoftware Heritage

tests: Refactor test checking origin browsing errors
ClosedPublic

Authored by anlambert on Apr 15 2020, 5:15 PM.

Details

Summary

Split the test_origin_request_errors pita test into multiple smaller ones,
use hypothesis and remove some no more needed mocks.

Depends on D3021.

Diff Detail

Repository
rDWAPPS Web applications
Branch
refactor-browse-origin-tests
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 11857
Build 17988: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 17987: arc lint + arc unit

Event Timeline

so much clearer!

Thanks.

Maybe adding some assert <mock>.called in the expected checks part would be for the best.

I'll let you decide ;)

swh/web/tests/browse/views/test_origin.py
465–466

I thought about adding:

assert mock_get_origin_visits.called

That way we are sure those mocks are indeed used (without checking too much).

Build has FAILED

Patch application report for D3022 (id=10735)

Could not rebase; Attempt merge onto 6cd93e8e8e...

Updating 6cd93e8e..651bddcf
Fast-forward
 .../browse/{views/utils => }/snapshot_context.py   | 339 ++++++++++++++++++++-
 swh/web/browse/utils.py                            | 328 +-------------------
 swh/web/browse/views/content.py                    |  10 +-
 swh/web/browse/views/directory.py                  |  12 +-
 swh/web/browse/views/origin.py                     |  18 +-
 swh/web/browse/views/release.py                    |   8 +-
 swh/web/browse/views/revision.py                   |  18 +-
 swh/web/browse/views/snapshot.py                   |   2 +-
 swh/web/browse/views/utils/__init__.py             |   0
 swh/web/tests/browse/test_snapshot_context.py      |  65 ++++
 swh/web/tests/browse/test_utils.py                 |  88 +-----
 swh/web/tests/browse/views/test_origin.py          | 222 +++++---------
 12 files changed, 527 insertions(+), 583 deletions(-)
 rename swh/web/browse/{views/utils => }/snapshot_context.py (74%)
 delete mode 100644 swh/web/browse/views/utils/__init__.py
 create mode 100644 swh/web/tests/browse/test_snapshot_context.py
Changes applied before test
commit 651bddcff6e28fa4508b8600af327e032221ec04
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Wed Apr 15 17:13:23 2020 +0200

    tests: Refactor test checking origin browsing errors
    
    Split the test_origin_request_errors pita test into multiple smaller ones,
    use hypothesis and remove some no more needed mocks.

commit 9ad1d27bd4e092161cfd1badf6814b560feeefc9
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue Apr 14 17:15:39 2020 +0200

    browse: Merge snapshot context related functions in dedicated module
    
    Related to T2360

Link to build: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/61/
See console output for more information: https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/61/console

Update:

  • add assert mock*.*.called checks
  • pytest.ini: Update filterwarnings after new hypothesis release (new commit)

Build is green

Patch application report for D3022 (id=10736)

Could not rebase; Attempt merge onto 6cd93e8e8e...

Updating 6cd93e8e..533628aa
Fast-forward
 pytest.ini                                         |   4 +-
 .../browse/{views/utils => }/snapshot_context.py   | 339 ++++++++++++++++++++-
 swh/web/browse/utils.py                            | 328 +-------------------
 swh/web/browse/views/content.py                    |  10 +-
 swh/web/browse/views/directory.py                  |  12 +-
 swh/web/browse/views/origin.py                     |  18 +-
 swh/web/browse/views/release.py                    |   8 +-
 swh/web/browse/views/revision.py                   |  18 +-
 swh/web/browse/views/snapshot.py                   |   2 +-
 swh/web/browse/views/utils/__init__.py             |   0
 swh/web/tests/browse/test_snapshot_context.py      |  65 ++++
 swh/web/tests/browse/test_utils.py                 |  88 +-----
 swh/web/tests/browse/views/test_origin.py          | 232 ++++++--------
 13 files changed, 539 insertions(+), 585 deletions(-)
 rename swh/web/browse/{views/utils => }/snapshot_context.py (74%)
 delete mode 100644 swh/web/browse/views/utils/__init__.py
 create mode 100644 swh/web/tests/browse/test_snapshot_context.py
Changes applied before test
commit 533628aa89a487d9f44936fb96dd117f2eb48fbc
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Wed Apr 15 18:11:58 2020 +0200

    pytest.ini: Update filterwarnings after new hypothesis release

commit 7d137314d28ff1b3593cc5848e3fc2938d7e5ca6
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Wed Apr 15 17:13:23 2020 +0200

    tests: Refactor test checking origin browsing errors
    
    Split the test_origin_request_errors pita test into multiple smaller ones,
    use hypothesis and remove some no more needed mocks.

commit 9ad1d27bd4e092161cfd1badf6814b560feeefc9
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Tue Apr 14 17:15:39 2020 +0200

    browse: Merge snapshot context related functions in dedicated module
    
    Related to T2360

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/62/ for more details.

This revision is now accepted and ready to land.Apr 15 2020, 6:24 PM