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


Python Bugzilla.fetch_from_cache方法代码示例

本文整理汇总了Python中perceval.backends.bugzilla.Bugzilla.fetch_from_cache方法的典型用法代码示例。如果您正苦于以下问题:Python Bugzilla.fetch_from_cache方法的具体用法?Python Bugzilla.fetch_from_cache怎么用?Python Bugzilla.fetch_from_cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在perceval.backends.bugzilla.Bugzilla的用法示例。


在下文中一共展示了Bugzilla.fetch_from_cache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_fetch_from_non_set_cache

# 需要导入模块: from perceval.backends.bugzilla import Bugzilla [as 别名]
# 或者: from perceval.backends.bugzilla.Bugzilla import fetch_from_cache [as 别名]
    def test_fetch_from_non_set_cache(self):
        """Test if a error is raised when the cache was not set"""

        bg = Bugzilla(BUGZILLA_SERVER_URL, max_bugs=5)

        with self.assertRaises(CacheError):
            _ = [bug for bug in bg.fetch_from_cache()]
开发者ID:grimoirelab,项目名称:perceval,代码行数:9,代码来源:test_bugzilla.py

示例2: test_fetch_from_empty_cache

# 需要导入模块: from perceval.backends.bugzilla import Bugzilla [as 别名]
# 或者: from perceval.backends.bugzilla.Bugzilla import fetch_from_cache [as 别名]
    def test_fetch_from_empty_cache(self):
        """Test if there are not any bugs returned when the cache is empty"""

        cache = Cache(self.tmp_path)
        bg = Bugzilla(BUGZILLA_SERVER_URL, max_bugs=5, cache=cache)

        cached_bugs = [bug for bug in bg.fetch_from_cache()]
        self.assertEqual(len(cached_bugs), 0)
开发者ID:grimoirelab,项目名称:perceval,代码行数:10,代码来源:test_bugzilla.py

示例3: test_fetch_from_cache

# 需要导入模块: from perceval.backends.bugzilla import Bugzilla [as 别名]
# 或者: from perceval.backends.bugzilla.Bugzilla import fetch_from_cache [as 别名]
    def test_fetch_from_cache(self):
        """Test whether the cache works"""

        requests = []
        bodies_csv = [read_file('data/bugzilla_buglist.csv'),
                      read_file('data/bugzilla_buglist_next.csv'),
                      ""]
        bodies_xml = [read_file('data/bugzilla_version.xml', mode='rb'),
                      read_file('data/bugzilla_bugs_details.xml', mode='rb'),
                      read_file('data/bugzilla_bugs_details_next.xml', mode='rb')]
        bodies_html = [read_file('data/bugzilla_bug_activity.html', mode='rb'),
                       read_file('data/bugzilla_bug_activity_empty.html', mode='rb')]

        def request_callback(method, uri, headers):
            if uri.startswith(BUGZILLA_BUGLIST_URL):
                body = bodies_csv.pop(0)
            elif uri.startswith(BUGZILLA_BUG_URL):
                body = bodies_xml.pop(0)
            else:
                body = bodies_html[len(requests) % 2]

            requests.append(httpretty.last_request())

            return (200, headers, body)

        httpretty.register_uri(httpretty.GET,
                               BUGZILLA_BUGLIST_URL,
                               responses=[
                                    httpretty.Response(body=request_callback) \
                                    for _ in range(3)
                               ])
        httpretty.register_uri(httpretty.GET,
                               BUGZILLA_BUG_URL,
                               responses=[
                                    httpretty.Response(body=request_callback) \
                                    for _ in range(2)
                               ])
        httpretty.register_uri(httpretty.GET,
                               BUGZILLA_BUG_ACTIVITY_URL,
                               responses=[
                                    httpretty.Response(body=request_callback) \
                                    for _ in range(7)
                               ])

        # First, we fetch the bugs from the server, storing them
        # in a cache
        cache = Cache(self.tmp_path)
        bg = Bugzilla(BUGZILLA_SERVER_URL, max_bugs=5, cache=cache)

        bugs = [bug for bug in bg.fetch()]
        self.assertEqual(len(requests), 13)

        # Now, we get the bugs from the cache.
        # The contents should be the same and there won't be
        # any new request to the server
        cached_bugs = [bug for bug in bg.fetch_from_cache()]
        self.assertEqual(len(cached_bugs), len(bugs))

        self.assertEqual(len(cached_bugs), 7)

        self.assertEqual(cached_bugs[0]['data']['bug_id'][0]['__text__'], '15')
        self.assertEqual(len(cached_bugs[0]['data']['activity']), 0)
        self.assertEqual(cached_bugs[0]['origin'], BUGZILLA_SERVER_URL)
        self.assertEqual(cached_bugs[0]['uuid'], '5a8a1e25dfda86b961b4146050883cbfc928f8ec')
        self.assertEqual(cached_bugs[0]['updated_on'], 1248276445.0)
        self.assertEqual(cached_bugs[0]['category'], 'bug')

        self.assertEqual(cached_bugs[6]['data']['bug_id'][0]['__text__'], '888')
        self.assertEqual(len(cached_bugs[6]['data']['activity']), 14)
        self.assertEqual(cached_bugs[6]['origin'], BUGZILLA_SERVER_URL)
        self.assertEqual(cached_bugs[6]['uuid'], 'b4009442d38f4241a4e22e3e61b7cd8ef5ced35c')
        self.assertEqual(cached_bugs[6]['updated_on'], 1439404330.0)
        self.assertEqual(cached_bugs[6]['category'], 'bug')

        self.assertEqual(len(requests), 13)
开发者ID:grimoirelab,项目名称:perceval,代码行数:77,代码来源:test_bugzilla.py


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