• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python support.mock_sack函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.support.mock_sack函数的典型用法代码示例。如果您正苦于以下问题:Python mock_sack函数的具体用法?Python mock_sack怎么用?Python mock_sack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_per_nevra_dict

 def test_per_nevra_dict(self):
     sack = support.mock_sack("main")
     pkgs = dnf.queries.by_name(sack, "lotus")
     dct = dnf.queries.per_nevra_dict(pkgs)
     self.assertItemsEqual(dct.keys(),
                           ["lotus-3-16.x86_64", "lotus-3-16.i686"])
     self.assertItemsEqual(dct.values(), pkgs)
开发者ID:lmacken,项目名称:dnf,代码行数:7,代码来源:test_queries.py


示例2: test_per_nevra_dict

 def test_per_nevra_dict(self):
     sack = support.mock_sack("main")
     pkgs = sack.query().filter(name="lotus")
     dct = dnf.query.per_nevra_dict(pkgs)
     self.assertCountEqual(dct.keys(),
                           ["lotus-3-16.x86_64", "lotus-3-16.i686"])
     self.assertCountEqual(dct.values(), pkgs)
开发者ID:Xake,项目名称:dnf,代码行数:7,代码来源:test_queries.py


示例3: test_recent

 def test_recent(self):
     sack = support.mock_sack("main")
     now = time.time()
     installed = support.MockQuery(sack.query().installed())
     installed[0].buildtime = now - 86400/2
     pkgs = installed.recent(1)
     self.assertEqual(len(pkgs), 1)
开发者ID:MattSturgeon,项目名称:dnf,代码行数:7,代码来源:test_queries.py


示例4: test_sanity

    def test_sanity(self):
        assert(os.access(support.repo("@System.repo"), os.R_OK))
        sack = support.mock_sack()
        assert(sack)
        self.assertEqual(len(sack), support.SYSTEM_NSOLVABLES)

        sack2 = support.MockBase("main", "updates").sack
        self.assertEqual(len(sack2), support.TOTAL_NSOLVABLES)
开发者ID:Aftermath,项目名称:dnf,代码行数:8,代码来源:test_sanity.py


示例5: test_find_installed_ni

    def test_find_installed_ni(self):
        """Test finding with an unistalled NEVRA."""
        sack = support.mock_sack('main')
        converter = dnf.history.TransactionConverter(sack)
        with self.assertRaises(dnf.exceptions.PackagesNotInstalledError) as ctx:
            converter._find_installed('none-1-0.noarch')

        self.assertEqual(ctx.exception.pkg_spec, 'none-1-0.noarch')
开发者ID:MattSturgeon,项目名称:dnf,代码行数:8,代码来源:test_history.py


示例6: test_update_not_found

    def test_update_not_found(self):
        base = dnf.Base()
        base._sack = support.mock_sack('updates')
        base._goal = goal = mock.create_autospec(hawkey.Goal)

        self.assertRaises(dnf.exceptions.PackageNotFoundError,
                          base.update, 'non-existent')
        self.assertEqual(goal.mock_calls, [])
开发者ID:lmacken,项目名称:dnf,代码行数:8,代码来源:test_update.py


示例7: test_installed_exact

 def test_installed_exact(self):
     sack = support.mock_sack()
     pkgs = dnf.queries.installed_exact(sack, "tour", "4.9-0", "noarch")
     self.assertEqual(len(pkgs), 0)
     pkgs = dnf.queries.installed_exact(sack, "tour", "5-0", "x86_64")
     self.assertEqual(len(pkgs), 0)
     pkgs = dnf.queries.installed_exact(sack, "tour", "5-0", "noarch")
     self.assertEqual(len(pkgs), 1)
开发者ID:lmacken,项目名称:dnf,代码行数:8,代码来源:test_queries.py


示例8: test_find_available_na

    def test_find_available_na(self):
        """Test finding with an unavailable NEVRA."""
        sack = support.mock_sack("main")
        converter = dnf.history.TransactionConverter(sack)
        with self.assertRaises(dnf.exceptions.PackagesNotAvailableError) as ctx:
            converter._find_available("none-1-0.noarch")

        self.assertEqual(ctx.exception.pkg_spec, "none-1-0.noarch")
开发者ID:pnemade,项目名称:dnf,代码行数:8,代码来源:test_history.py


示例9: test_installed_exact

 def test_installed_exact(self):
     sack = support.mock_sack()
     pkgs = sack.query().installed().nevra("tour-4.9-0.noarch")
     self.assertEqual(len(pkgs), 0)
     pkgs = sack.query().installed().nevra("tour-5-0.x86_64")
     self.assertEqual(len(pkgs), 0)
     pkgs = sack.query().installed().nevra("tour-5-0.noarch")
     self.assertEqual(len(pkgs), 1)
开发者ID:Xake,项目名称:dnf,代码行数:8,代码来源:test_queries.py


示例10: test_recent_pkgs

 def test_recent_pkgs(self):
     sack = support.mock_sack("main")
     now = time.time()
     installed = [support.MockPackage(str(p))
                  for p in sack.query().installed().run()]
     installed[0].buildtime = now - 86400/2
     pkgs = dnf.query.recent_pkgs(installed, 1)
     self.assertEqual(len(pkgs), 1)
开发者ID:Aftermath,项目名称:dnf,代码行数:8,代码来源:test_queries.py


示例11: test_update_not_found

    def test_update_not_found(self):
        base = dnf.Base()
        base._sack = support.mock_sack('updates')
        base._goal = goal = mock.create_autospec(dnf.goal.Goal)

        with self.assertRaises(dnf.exceptions.MarkingError) as context:
            base.upgrade('non-existent')
        self.assertEqual(context.exception.pkg_spec, 'non-existent')
        self.assertEqual(goal.mock_calls, [])
开发者ID:IMFTC,项目名称:dnf,代码行数:9,代码来源:test_update.py


示例12: test_duplicities

 def test_duplicities(self):
     sack = support.mock_sack()
     pepper = sack.query().installed().filter(name="pepper")
     # make sure 'pepper' package exists:
     self.assertEqual(len(pepper), 1)
     # we shouldn't see it more than once with a tricky query below:
     res = sack.query().installed().filter(name=["pep*", "*per"])
     res_set = set(res)
     self.assertEqual(len(res), len(res_set))
开发者ID:Xake,项目名称:dnf,代码行数:9,代码来源:test_queries.py


示例13: test_iter_userinstalled

 def test_iter_userinstalled(self):
     """Test iter_userinstalled with a package installed by the user."""
     base = support.MockBase()
     self._setup_packages(base.history)
     base._sack = support.mock_sack('main')
     pkg, = base.sack.query().installed().filter(name='pepper')
     base.history.set_repo(pkg, "main")
     base.history.set_reason(pkg, SwdbReason.USER)
     self.assertEqual(base.history.user_installed(pkg), True)
     self.assertEqual(base.history.repo(pkg), 'main')
开发者ID:edynox,项目名称:dnf,代码行数:10,代码来源:test_base.py


示例14: test_iter_userinstalled_badreason

 def test_iter_userinstalled_badreason(self):
     """Test iter_userinstalled with a package installed for a wrong reason."""
     base = support.MockBase()
     base._sack = support.mock_sack('main')
     self._setup_packages(base.history)
     pkg, = base.sack.query().installed().filter(name='pepper')
     base.history.set_reason(pkg, SwdbReason.DEP)
     base.history.set_repo(pkg, "main")
     self.assertEqual(base.history.user_installed(pkg), False)
     self.assertEqual(base.history.repo(pkg), 'main')
开发者ID:edynox,项目名称:dnf,代码行数:10,代码来源:test_base.py


示例15: test_latest

 def test_latest(self):
     sack = support.mock_sack("old_versions")
     tours = sack.query().filter(name="tour")
     all_tours = sorted(tours.run(), reverse=True)
     head2 = all_tours[0:2]
     tail2 = all_tours[2:]
     pkgs = tours.latest(2).run()
     self.assertEqual(pkgs, head2)
     pkgs = tours.latest(-2).run()
     self.assertEqual(pkgs, tail2)
开发者ID:MattSturgeon,项目名称:dnf,代码行数:10,代码来源:test_queries.py


示例16: test_autoremove

 def test_autoremove(self):
     sack = support.mock_sack("main")
     base = support.MockBase("main")
     installed = sack.query().installed()
     for pkg in installed:
         base.yumdb.get_package(pkg).reason = "dep"
     hole = installed.filter(name="hole")[0]
     base.yumdb.get_package(hole).reason = "user"
     pkgs = installed.unneeded(sack, base.yumdb)
     self.assertEqual(len(pkgs), support.TOTAL_RPMDB_COUNT-1)
开发者ID:MattSturgeon,项目名称:dnf,代码行数:10,代码来源:test_queries.py


示例17: test_iter_userinstalled_badfromrepo

 def test_iter_userinstalled_badfromrepo(self):
     """Test iter_userinstalled with a package installed from a bad repository."""
     base = support.MockBase()
     base._sack = support.mock_sack('main')
     self._setup_packages(base.history)
     pkg, = base.sack.query().installed().filter(name='pepper')
     base.history.set_repo(pkg, "anakonda")
     base.history.set_reason(pkg, SwdbReason.USER)
     self.assertEqual(base.history.user_installed(pkg), False)
     self.assertEqual(base.history.repo(pkg), 'anakonda')
开发者ID:edynox,项目名称:dnf,代码行数:10,代码来源:test_base.py


示例18: test_by_file

    def test_by_file(self):
        # check sanity first:
        sack = support.mock_sack()
        q = sack.query().filter(file__eq="/raised/smile")
        self.assertEqual(len(q.run()), 1)
        pkg = q.result[0]

        # now the query:
        res = dnf.queries.by_file(sack, "/raised/smile")
        self.assertEqual(len(res), 1)
        self.assertEqual(pkg, res[0])
开发者ID:lmacken,项目名称:dnf,代码行数:11,代码来源:test_queries.py


示例19: setUp

    def setUp(self):
        self._base = dnf.cli.cli.BaseCli()
        self._base._sack = support.mock_sack('main', 'updates')
        self._base._goal = dnf.goal.Goal(self._base.sack)

        main_repo = support.MockRepo('main', None)
        main_repo.metadata = mock.Mock(comps_fn=support.COMPS_PATH)
        main_repo.enable()
        self._base.repos.add(main_repo)

        self._base.output.term = support.MockTerminal()
        self._base.downgrade = mock.Mock(wraps=self._base.downgrade)
开发者ID:IMFTC,项目名称:dnf,代码行数:12,代码来源:test_cli.py


示例20: test_iter_userinstalled

    def test_iter_userinstalled(self):
        """Test iter_userinstalled with a package installed by the user."""
        base = dnf.Base()
        base._sack = support.mock_sack('main')
        base._priv_yumdb = support.MockYumDB()
        pkg, = base.sack.query().installed().filter(name='pepper')
        base._yumdb.get_package(pkg).get = {'reason': 'user', 'from_repo': 'main'}.get

        iterator = base.iter_userinstalled()

        self.assertEqual(next(iterator), pkg)
        self.assertRaises(StopIteration, next, iterator)
开发者ID:haghabozorgi,项目名称:dnf,代码行数:12,代码来源:test_base.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python support.patch_std_streams函数代码示例发布时间:2022-05-27
下一篇:
Python support.installed_but函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap