当前位置: 首页>>代码示例>>Python>>正文


Python UploadPackHandler.progress方法代码示例

本文整理汇总了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))
开发者ID:ardumont,项目名称:dulwich,代码行数:53,代码来源:test_server.py

示例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()))
开发者ID:tmc,项目名称:dulwich,代码行数:52,代码来源:test_server.py

示例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))
开发者ID:jaraco,项目名称:dulwich,代码行数:41,代码来源:test_server.py


注:本文中的dulwich.server.UploadPackHandler.progress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。