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


Python support.mock_sack函数代码示例

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


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


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