MCPcopy Create free account
hub / github.com/libgit2/pygit2 / test_push_transfer_progress

Function test_push_transfer_progress

test/test_remote.py:417–447  ·  view source on GitHub ↗
(
    origin: Repository, clone: Repository, remote: Remote
)

Source from the content-addressed store, hash-verified

415
416
417def test_push_transfer_progress(
418 origin: Repository, clone: Repository, remote: Remote
419) -> None:
420 tip = clone[clone.head.target]
421 new_tip_id = clone.create_commit(
422 'refs/heads/master',
423 tip.author,
424 tip.author,
425 'empty commit',
426 tip.tree.id,
427 [tip.id],
428 )
429
430 # NOTE: We're currently not testing bytes_pushed due to a bug in libgit2
431 # 1.9.0: it passes a junk value for bytes_pushed when pushing to a remote
432 # on the local filesystem, as is the case in this unit test. (When pushing
433 # to a remote over the network, the value is correct.)
434 class MyCallbacks(pygit2.RemoteCallbacks):
435 def push_transfer_progress(
436 self, objects_pushed: int, total_objects: int, bytes_pushed: int
437 ) -> None:
438 self.objects_pushed = objects_pushed
439 self.total_objects = total_objects
440
441 assert origin.branches['master'].target == tip.id
442
443 callbacks = MyCallbacks()
444 remote.push(['refs/heads/master'], callbacks=callbacks)
445 assert callbacks.objects_pushed == 1
446 assert callbacks.total_objects == 1
447 assert origin.branches['master'].target == new_tip_id
448
449
450@pytest.mark.parametrize('reject_from', ['push_transfer_progress', 'push_negotiation'])

Callers

nothing calls this directly

Calls 2

pushMethod · 0.80
MyCallbacksClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…