Page MenuHomeSoftware Heritage

tests: Enable type-checking on storage test functions.
ClosedPublic

Authored by vlorentz on Oct 7 2020, 10:02 AM.

Details

Summary

By adding a simple type annotation to the test functions' signature.

Depends on D4159.

Diff Detail

Repository
rDCIDX Metadata indexer
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vlorentz retitled this revision from tests: Enable type-checking on test functions. to tests: Enable type-checking on storage test functions..Oct 7 2020, 10:03 AM

Build is green

Patch application report for D4169 (id=14679)

Could not rebase; Attempt merge onto 51b10e891d...

Updating 51b10e8..7ff2eec
Fast-forward
 swh/indexer/ctags.py                         |   2 +-
 swh/indexer/fossology_license.py             |   4 +-
 swh/indexer/indexer.py                       |  30 ++-
 swh/indexer/metadata.py                      |   6 +-
 swh/indexer/mimetype.py                      |  21 +-
 swh/indexer/origin_head.py                   |   4 +-
 swh/indexer/storage/__init__.py              |  26 +-
 swh/indexer/storage/api/client.py            |   3 +
 swh/indexer/storage/api/serializers.py       |  26 ++
 swh/indexer/storage/api/server.py            |   9 +-
 swh/indexer/storage/db.py                    |  18 +-
 swh/indexer/storage/in_memory.py             |  15 +-
 swh/indexer/storage/interface.py             |  25 +-
 swh/indexer/tests/storage/conftest.py        |   3 +-
 swh/indexer/tests/storage/test_converters.py |  12 +-
 swh/indexer/tests/storage/test_metrics.py    |   8 +-
 swh/indexer/tests/storage/test_server.py     |  14 +-
 swh/indexer/tests/storage/test_storage.py    | 380 +++++++++++++++++----------
 swh/indexer/tests/test_fossology_license.py  |  16 ++
 swh/indexer/tests/test_mimetype.py           |   4 +-
 swh/indexer/tests/utils.py                   |  16 +-
 21 files changed, 413 insertions(+), 229 deletions(-)
 create mode 100644 swh/indexer/storage/api/serializers.py
Changes applied before test
commit 7ff2eec02be23a01538caeea02fe97bc1008dafb
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Oct 7 10:01:26 2020 +0200

    tests: Enable type-checking on test functions.
    
    By adding a simple type annotation to the test functions' signature.

commit 44cee8f213f26e01aa63519a8c21962b2fca460b
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Oct 6 15:42:54 2020 +0200

    Make base indexers generic, with the result of index() as their type parameter.
    
    So the type of results can be statically checked, instead of needing to
    assert it to please mypy.

commit c3caf300830030f0cd1b3002d715e430582db8f1
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Oct 6 15:35:39 2020 +0200

    mimetype: use ContentMimetypeRow in the storage interface instead of dicts.
    
    This temporarily adds mess in the generic tests to support both rows and dicts,
    but I'll remove it once I migrated all endpoints.

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

Build is green

Patch application report for D4169 (id=14680)

Could not rebase; Attempt merge onto 51b10e891d...

Updating 51b10e8..e8e94cf
Fast-forward
 swh/indexer/ctags.py                         |   2 +-
 swh/indexer/fossology_license.py             |   4 +-
 swh/indexer/indexer.py                       |  30 ++-
 swh/indexer/metadata.py                      |   6 +-
 swh/indexer/mimetype.py                      |  21 +-
 swh/indexer/origin_head.py                   |   4 +-
 swh/indexer/storage/__init__.py              |  26 +-
 swh/indexer/storage/api/client.py            |   3 +
 swh/indexer/storage/api/serializers.py       |  26 ++
 swh/indexer/storage/api/server.py            |   9 +-
 swh/indexer/storage/db.py                    |  18 +-
 swh/indexer/storage/in_memory.py             |  15 +-
 swh/indexer/storage/interface.py             |  25 +-
 swh/indexer/tests/storage/conftest.py        |   3 +-
 swh/indexer/tests/storage/test_converters.py |  12 +-
 swh/indexer/tests/storage/test_metrics.py    |   8 +-
 swh/indexer/tests/storage/test_server.py     |  14 +-
 swh/indexer/tests/storage/test_storage.py    | 380 +++++++++++++++++----------
 swh/indexer/tests/test_fossology_license.py  |  16 ++
 swh/indexer/tests/test_mimetype.py           |   4 +-
 swh/indexer/tests/utils.py                   |  16 +-
 21 files changed, 413 insertions(+), 229 deletions(-)
 create mode 100644 swh/indexer/storage/api/serializers.py
Changes applied before test
commit e8e94cf237471636e84ceac5d1740cfa7a982f90
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Wed Oct 7 10:01:26 2020 +0200

    tests: Enable type-checking on storage test functions.
    
    By adding a simple type annotation to the test functions' signature.

commit 44cee8f213f26e01aa63519a8c21962b2fca460b
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Oct 6 15:42:54 2020 +0200

    Make base indexers generic, with the result of index() as their type parameter.
    
    So the type of results can be statically checked, instead of needing to
    assert it to please mypy.

commit c3caf300830030f0cd1b3002d715e430582db8f1
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Oct 6 15:35:39 2020 +0200

    mimetype: use ContentMimetypeRow in the storage interface instead of dicts.
    
    This temporarily adds mess in the generic tests to support both rows and dicts,
    but I'll remove it once I migrated all endpoints.

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

This revision is now accepted and ready to land.Oct 7 2020, 10:56 AM