Page MenuHomeSoftware Heritage

api.classes: Open swh.core.api.classes.stream_results
ClosedPublic

Authored by ardumont on Jul 31 2020, 12:58 PM.

Details

Summary

This avoids duplication which is growing (right now storage and search proposes
the same pattern in different functions).

Related to T645

Test Plan

tox

Diff Detail

Event Timeline

Build is green

Patch application report for D3664 (id=12898)

Rebasing onto d639fa9f97...

Current branch diff-target is up to date.
Changes applied before test
commit cd5fab9366b4f5913e44f58e7ec451b985c2fb07
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Fri Jul 31 12:58:30 2020 +0200

    api.classes: Open swh.core.api.classes.stream_results
    
    This avoids duplication which is growing (right now storage and search proposes
    the same pattern in different functions).
    
    Related to T645

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

vlorentz added a subscriber: vlorentz.

Great, thanks.

Could you also add a test for when page_result.results is empty?

swh/core/api/tests/test_classes.py
27

split here into two tests

This revision is now accepted and ready to land.Jul 31 2020, 1:05 PM
swh/core/api/classes.py
29

add let's add some typing:

def stream_results(f: Callable[[...], PageResult[TResult, TToken], *args, **kwargs) -> Iterable[TResult]`
swh/core/api/classes.py
29

yeah, was going to do it after lunch break
thanks.

Adapt according to review:

  • Add type to new function
  • Split tests
  • Add new test for empty result
swh/core/api/classes.py
37

nitpick: should be ArgumentError, actually.

vlorentz added inline comments.
swh/core/api/classes.py
37

uh, actually no, nvm

Build is green

Patch application report for D3664 (id=12904)

Rebasing onto d639fa9f97...

Current branch diff-target is up to date.
Changes applied before test
commit 6d49f04a6b84d365799d00f85fc4ab2aa15b6537
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Fri Jul 31 12:58:30 2020 +0200

    api.classes: Open swh.core.api.classes.stream_results
    
    This avoids duplication which is growing (right now storage and search proposes
    the same pattern in different functions).
    
    Related to T645

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