Page MenuHomeSoftware Heritage

test_checks: Use pytest.mark.parametrize
ClosedPublic

Authored by ardumont on Oct 12 2020, 1:49 PM.

Details

Summary

This will allow to be a bit more lenient on those checks (then adding some more sample tests without
the need to craft new tests, see D4232).

Test Plan

tox

Diff Detail

Repository
rDDEP Push deposit
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 16168
Build 24873: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 24872: arc lint + arc unit

Event Timeline

Build is green

Patch application report for D4231 (id=14936)

Could not rebase; Attempt merge onto 419c1b26d0...

Updating 419c1b26..8861413d
Fast-forward
 swh/deposit/cli/client.py                          |  38 +-
 swh/deposit/client.py                              | 218 +++++++----
 swh/deposit/tests/api/test_checks.py               |  94 +++--
 swh/deposit/tests/cli/test_client.py               | 401 ++++++++++++++++-----
 .../1_servicedocument                              |  26 ++
 .../1_test_123_metadata                            |  10 +
 .../1_test_123_status                              |  10 +
 .../1_test_321_status                              |   8 +
 8 files changed, 566 insertions(+), 239 deletions(-)
 create mode 100644 swh/deposit/tests/data/https_deposit.test.updateswhid/1_servicedocument
 create mode 100644 swh/deposit/tests/data/https_deposit.test.updateswhid/1_test_123_metadata
 create mode 100644 swh/deposit/tests/data/https_deposit.test.updateswhid/1_test_123_status
 create mode 100644 swh/deposit/tests/data/https_deposit.test.updateswhid/1_test_321_status
Changes applied before test
commit 8861413d52e2e7719b5a70b0bbc9f7876a68891b
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Mon Oct 12 13:49:55 2020 +0200

    test_checks: Use pytest.mark.parametrize
    
    This will allow to improve the existing code and add some more sample without
    the need to craft new tests.

commit 866ec64139b375adb93352414751cffd4d756ea2
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Mon Oct 12 08:11:30 2020 +0200

    deposit_client: Allow deposit metadata update on completed deposit
    
    Related to T2538

commit 0fe94348f60dcf2c748b95f072e502bf4d4eeab9
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Sun Oct 11 12:13:04 2020 +0200

    test_client: Move redundant tests setup into fixtures

commit 2150833f440605c5c48b9fef0369f2ccd752f046
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Sat Oct 10 08:13:58 2020 +0200

    test_client: Explicit the possible format outputs

commit 8e99386fa17d22b0ec1eb0fc4a806b233027deca
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Fri Oct 9 16:23:17 2020 +0200

    deposit.client: Improve cli error messages and add missing coverage
    
    This adds the missing checks on:
    - no actionable command
    - missing --deposit-id when specifying the --replace flag
    - some more incompatible checks command scenario

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

vlorentz added inline comments.
swh/deposit/tests/api/test_checks.py
14–25

what is the difference in handling between these two?

36–56

that's a little hard to read, with the metadata and errors mixed together :/

swh/deposit/tests/api/test_checks.py
14–25

either name or title needs to be there.
The first one provides the name, the other the title.
And as they both declare the required author field, their check pass.

36–56

How to do better though?

i'm planning on changing the current checks and adding plenty of tests whose body is the same does not excite me much.

ardumont added inline comments.
swh/deposit/tests/api/test_checks.py
36–56

to clarify...

... "and this" does not excite me much to copy/paste those body instructions all around.

vlorentz added inline comments.
swh/deposit/tests/api/test_checks.py
14–25

oh right, I missed that name != title

36–56

I don't know. :/

This revision is now accepted and ready to land.Oct 12 2020, 3:04 PM

Rebase
(move the commit down the stack so it can land soon)

Build is green

Patch application report for D4231 (id=14968)

Rebasing onto 69e527dc23...

Current branch diff-target is up to date.
Changes applied before test
commit 0e0b342d9b6505d208052de7cd2a01c864e76edd
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Mon Oct 12 13:49:55 2020 +0200

    test_checks: Use pytest.mark.parametrize
    
    This will allow to improve the existing code and add some more sample without
    the need to craft new tests.

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

This revision was automatically updated to reflect the committed changes.