本文整理汇总了Python中dulwich.server.UploadPackHandler.set_client_capabilities方法的典型用法代码示例。如果您正苦于以下问题:Python UploadPackHandler.set_client_capabilities方法的具体用法?Python UploadPackHandler.set_client_capabilities怎么用?Python UploadPackHandler.set_client_capabilities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dulwich.server.UploadPackHandler
的用法示例。
在下文中一共展示了UploadPackHandler.set_client_capabilities方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UploadPackHandlerTestCase
# 需要导入模块: from dulwich.server import UploadPackHandler [as 别名]
# 或者: from dulwich.server.UploadPackHandler import set_client_capabilities [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 set_client_capabilities [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 set_client_capabilities [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))
示例4: UploadPackHandlerTestCase
# 需要导入模块: from dulwich.server import UploadPackHandler [as 别名]
# 或者: from dulwich.server.UploadPackHandler import set_client_capabilities [as 别名]
class UploadPackHandlerTestCase(TestCase):
def setUp(self):
self._handler = UploadPackHandler(None, None, None)
def test_set_client_capabilities(self):
try:
self._handler.set_client_capabilities([])
except GitProtocolError:
self.fail()
try:
self._handler.set_client_capabilities([
'multi_ack', 'side-band-64k', 'thin-pack', 'ofs-delta'])
except GitProtocolError:
self.fail()
def test_set_client_capabilities_error(self):
self.assertRaises(GitProtocolError,
self._handler.set_client_capabilities,
['weird_ack_level', 'ofs-delta'])
try:
self._handler.set_client_capabilities(['include-tag'])
except GitProtocolError:
self.fail()