本文整理匯總了Python中dulwich.server.UploadPackHandler.progress方法的典型用法代碼示例。如果您正苦於以下問題:Python UploadPackHandler.progress方法的具體用法?Python UploadPackHandler.progress怎麽用?Python UploadPackHandler.progress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dulwich.server.UploadPackHandler
的用法示例。
在下文中一共展示了UploadPackHandler.progress方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: UploadPackHandlerTestCase
# 需要導入模塊: from dulwich.server import UploadPackHandler [as 別名]
# 或者: from dulwich.server.UploadPackHandler import progress [as 別名]
class UploadPackHandlerTestCase(TestCase):
def setUp(self):
super(UploadPackHandlerTestCase, self).setUp()
self._repo = MemoryRepo.init_bare([], {})
backend = DictBackend({b'/': self._repo})
self._handler = UploadPackHandler(
backend, [b'/', b'host=lolcathost'], TestProto())
def test_progress(self):
caps = self._handler.required_capabilities()
self._handler.set_client_capabilities(caps)
self._handler.progress(b'first message')
self._handler.progress(b'second message')
self.assertEqual(b'first message',
self._handler.proto.get_received_line(2))
self.assertEqual(b'second message',
self._handler.proto.get_received_line(2))
self.assertRaises(IndexError, self._handler.proto.get_received_line, 2)
def test_no_progress(self):
caps = list(self._handler.required_capabilities()) + [b'no-progress']
self._handler.set_client_capabilities(caps)
self._handler.progress(b'first message')
self._handler.progress(b'second message')
self.assertRaises(IndexError, self._handler.proto.get_received_line, 2)
def test_get_tagged(self):
refs = {
b'refs/tags/tag1': ONE,
b'refs/tags/tag2': TWO,
b'refs/heads/master': FOUR, # not a tag, no peeled value
}
# repo needs to peel this object
self._repo.object_store.add_object(make_commit(id=FOUR))
self._repo.refs._update(refs)
peeled = {
b'refs/tags/tag1': b'1234' * 10,
b'refs/tags/tag2': b'5678' * 10,
}
self._repo.refs._update_peeled(peeled)
caps = list(self._handler.required_capabilities()) + [b'include-tag']
self._handler.set_client_capabilities(caps)
self.assertEqual({b'1234' * 10: ONE, b'5678' * 10: TWO},
self._handler.get_tagged(refs, repo=self._repo))
# non-include-tag case
caps = self._handler.required_capabilities()
self._handler.set_client_capabilities(caps)
self.assertEqual({}, self._handler.get_tagged(refs, repo=self._repo))
示例2: UploadPackHandlerTestCase
# 需要導入模塊: from dulwich.server import UploadPackHandler [as 別名]
# 或者: from dulwich.server.UploadPackHandler import progress [as 別名]
class UploadPackHandlerTestCase(TestCase):
def setUp(self):
self._backend = DictBackend({"/": BackendRepo()})
self._handler = UploadPackHandler(self._backend,
["/", "host=lolcathost"], None, None)
self._handler.proto = TestProto()
def test_progress(self):
caps = self._handler.required_capabilities()
self._handler.set_client_capabilities(caps)
self._handler.progress('first message')
self._handler.progress('second message')
self.assertEqual('first message',
self._handler.proto.get_received_line(2))
self.assertEqual('second message',
self._handler.proto.get_received_line(2))
self.assertEqual(None, self._handler.proto.get_received_line(2))
def test_no_progress(self):
caps = list(self._handler.required_capabilities()) + ['no-progress']
self._handler.set_client_capabilities(caps)
self._handler.progress('first message')
self._handler.progress('second message')
self.assertEqual(None, self._handler.proto.get_received_line(2))
def test_get_tagged(self):
refs = {
'refs/tags/tag1': ONE,
'refs/tags/tag2': TWO,
'refs/heads/master': FOUR, # not a tag, no peeled value
}
peeled = {
'refs/tags/tag1': '1234',
'refs/tags/tag2': '5678',
}
class TestRepo(object):
def get_peeled(self, ref):
return peeled.get(ref, refs[ref])
caps = list(self._handler.required_capabilities()) + ['include-tag']
self._handler.set_client_capabilities(caps)
self.assertEquals({'1234': ONE, '5678': TWO},
self._handler.get_tagged(refs, repo=TestRepo()))
# non-include-tag case
caps = self._handler.required_capabilities()
self._handler.set_client_capabilities(caps)
self.assertEquals({}, self._handler.get_tagged(refs, repo=TestRepo()))
示例3: UploadPackHandlerTestCase
# 需要導入模塊: from dulwich.server import UploadPackHandler [as 別名]
# 或者: from dulwich.server.UploadPackHandler import progress [as 別名]
class UploadPackHandlerTestCase(TestCase):
def setUp(self):
super(UploadPackHandlerTestCase, self).setUp()
self._repo = MemoryRepo.init_bare([], {})
backend = DictBackend({"/": self._repo})
self._handler = UploadPackHandler(backend, ["/", "host=lolcathost"], TestProto())
def test_progress(self):
caps = self._handler.required_capabilities()
self._handler.set_client_capabilities(caps)
self._handler.progress("first message")
self._handler.progress("second message")
self.assertEqual("first message", self._handler.proto.get_received_line(2))
self.assertEqual("second message", self._handler.proto.get_received_line(2))
self.assertRaises(IndexError, self._handler.proto.get_received_line, 2)
def test_no_progress(self):
caps = list(self._handler.required_capabilities()) + ["no-progress"]
self._handler.set_client_capabilities(caps)
self._handler.progress("first message")
self._handler.progress("second message")
self.assertRaises(IndexError, self._handler.proto.get_received_line, 2)
def test_get_tagged(self):
refs = {"refs/tags/tag1": ONE, "refs/tags/tag2": TWO, "refs/heads/master": FOUR} # not a tag, no peeled value
# repo needs to peel this object
self._repo.object_store.add_object(make_commit(id=FOUR))
self._repo.refs._update(refs)
peeled = {"refs/tags/tag1": "1234" * 10, "refs/tags/tag2": "5678" * 10}
self._repo.refs._update_peeled(peeled)
caps = list(self._handler.required_capabilities()) + ["include-tag"]
self._handler.set_client_capabilities(caps)
self.assertEqual({"1234" * 10: ONE, "5678" * 10: TWO}, self._handler.get_tagged(refs, repo=self._repo))
# non-include-tag case
caps = self._handler.required_capabilities()
self._handler.set_client_capabilities(caps)
self.assertEqual({}, self._handler.get_tagged(refs, repo=self._repo))