Page MenuHomeSoftware Heritage

test_client: Migrate nominal collection scenario to use requests_mock_datadir
ClosedPublic

Authored by ardumont on Oct 8 2020, 6:41 PM.

Details

Summary

Motivation: I want to understand tests without reading through the mocks...
I also want to improve the coverage in there because D4183 diff showed
it's missing a lot.

full disclosure, I don't trust nor like much that part of the code, so i'm trying
to give it some love nonetheless.

... Prior to actually open the new swhid parameter in the cli.

Test Plan

tox

Diff Detail

Repository
rDDEP Push deposit
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D4204 (id=14832)

Could not rebase; Attempt merge onto cd9c04afe6...

Updating cd9c04af..764e65dd
Fast-forward
 conftest.py                                        |   6 +-
 pytest.ini                                         |   2 +-
 swh/deposit/cli/client.py                          | 109 +++++++++++----------
 swh/deposit/tests/cli/test_client.py               |  18 ++--
 .../data/https_deposit.swh.test/1_servicedocument  |  26 +++++
 5 files changed, 103 insertions(+), 58 deletions(-)
 create mode 100644 swh/deposit/tests/data/https_deposit.swh.test/1_servicedocument
Changes applied before test
commit 764e65dd645c3cd84c3d8a7dc23bb541b21b7592
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Thu Oct 8 18:41:51 2020 +0200

    test_client: Start using requests_mock_datadir instead of mock

commit 7dc727087b99159335e3daf90b5a1c4180ebf5e6
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Oct 7 15:56:09 2020 +0200

    cli.client: Add types

commit 98dcf27419726acb0e3cefaf1859346abffa4546
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Oct 7 15:08:29 2020 +0200

    conftest: Declare swh.core pytest_plugin

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

swh/deposit/tests/cli/test_client.py
37

It took me too much time to boostrap this...

got bitten by the ../data ¯\_(ツ)_/¯

Build is green

Patch application report for D4204 (id=14835)

Could not rebase; Attempt merge onto cd9c04afe6...

Updating cd9c04af..2b4ad2cf
Fast-forward
 conftest.py                                        |   6 +-
 pytest.ini                                         |   2 +-
 swh/deposit/cli/client.py                          | 109 +++++++++++----------
 swh/deposit/tests/cli/test_client.py               |  18 ++--
 .../data/https_deposit.swh.test/1_servicedocument  |  26 +++++
 5 files changed, 103 insertions(+), 58 deletions(-)
 create mode 100644 swh/deposit/tests/data/https_deposit.swh.test/1_servicedocument
Changes applied before test
commit 2b4ad2cfe1927507b0e182ec3f15a3a733ad5ae2
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Thu Oct 8 18:41:51 2020 +0200

    test_client: Migrate collection ok test scenario to use requests_mock_datadir
    
    instead of mock

commit 7dc727087b99159335e3daf90b5a1c4180ebf5e6
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Oct 7 15:56:09 2020 +0200

    cli.client: Add types

commit 98dcf27419726acb0e3cefaf1859346abffa4546
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Oct 7 15:08:29 2020 +0200

    conftest: Declare swh.core pytest_plugin

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

ardumont retitled this revision from test_client: Start using requests_mock_datadir instead of mock to test_client: Migrate nominal collection scenario to use requests_mock_datadir.Oct 8 2020, 7:39 PM
ardumont edited the summary of this revision. (Show Details)

This is a very nice idea to try and mock less things with tests.

It's possible we did not have that pytest plugin at the time ;)
Now i'm refactoring the hell out of those which i found hard to read \o/

This revision is now accepted and ready to land.Oct 9 2020, 11:36 AM
ardumont edited the summary of this revision. (Show Details)

Improve commit sentencex

Build is green

Patch application report for D4204 (id=14861)

Rebasing onto 6b7d5336f7...

Current branch diff-target is up to date.
Changes applied before test
commit b9e98c0c96ba237e73877a9d4798b5be893a38d1
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Thu Oct 8 18:41:51 2020 +0200

    test_client: Migrate nominal collection scenario to use requests_mock_datadir
    
    instead of mocks.

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