Page MenuHomeSoftware Heritage

Revisions walker: Add methods to query produced history state
ClosedPublic

Authored by anlambert on Apr 24 2019, 11:34 AM.

Details

Summary

Add methods is_history_truncated and missing_revisions to check if the produced
history got truncated or not.

Related T1677

Diff Detail

Repository
rDSTO Storage manager
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

vlorentz added a subscriber: vlorentz.
vlorentz added inline comments.
swh/storage/tests/algos/test_revisions_walker.py
292

Why did you replace the decorator with a with?

297–302
revs_lists_truncated = [None if hash_to_hex(rev['id']) == _rev_missing else rev
                        for rev in _revisions_list]
314–319
else:
    self.assertEqual(revs_walker.missing_revisions(), set())
This revision is now accepted and ready to land.May 6 2019, 11:40 AM
swh/storage/tests/algos/test_revisions_walker.py
292

Because I wanted to use the new truncated_history argument as a keyword one in tests implementation for better readability.

297–302

list comprehension, ack

314–319

ack

swh/storage/tests/algos/test_revisions_walker.py
292

Doesn't this work?

@patch('swh.storage.storage.Storage')
def check_revisions_ordering(self, rev_walker_type, expected_result, truncated_history, MockStorage):
swh/storage/tests/algos/test_revisions_walker.py
292

Nope, got this kind of error when proceeding like this:

swh/storage/tests/algos/test_revisions_walker.py:404: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = (<swh.storage.tests.algos.test_revisions_walker.RevisionsWalkerTest testMethod=test_revisions_walker_truncated_history...40c85c10ac0b6423b61554d', '9c5051397e5c2e0c258bb639c3dd34406584ca10'], <MagicMock name='Storage' id='139885825057680'>)
keywargs = {'truncated_history': True}, extra_args = [<MagicMock name='Storage' id='139885825057680'>], entered_patchers = [<unittest.mock._patch object at 0x7f39c1691278>]
exc_info = (<class 'TypeError'>, TypeError("check_revisions_ordering() got multiple values for argument 'truncated_history'",), <traceback object at 0x7f39b4e097c8>), patching = <unittest.mock._patch object at 0x7f39c1691278>
arg = <MagicMock name='Storage' id='139885825057680'>

    @wraps(func)
    def patched(*args, **keywargs):
        extra_args = []
        entered_patchers = []
    
        exc_info = tuple()
        try:
            for patching in patched.patchings:
                arg = patching.__enter__()
                entered_patchers.append(patching)
                if patching.attribute_name is not None:
                    keywargs.update(arg)
                elif patching.new is DEFAULT:
                    extra_args.append(arg)
    
            args += tuple(extra_args)
>           return func(*args, **keywargs)
E           TypeError: check_revisions_ordering() got multiple values for argument 'truncated_history'

/usr/lib/python3.5/unittest/mock.py:1159: TypeError

Update:

  • address comments
  • update current year in copyright for modified files
This revision was automatically updated to reflect the committed changes.