def test_dependencies_missing_ok_when_ignore(self): pkgs = {'a': self._new_pkg(['b'])} pkg_sto = storage.BasePkgStorage() pkg_sto._pkgs = pkgs self.assertEqual(['b'], sorted( pkg_sto.get_dependencies('a', ignore_missing=True)))
def test_dependencies_with_maxdepth_1_return_direct_deps(self): pkgs = { 'a': self._new_pkg(['b']), 'b': self._new_pkg(['c']), 'c': self._new_pkg() } pkg_sto = storage.BasePkgStorage() pkg_sto._pkgs = pkgs self.assertEqual(['b'], sorted(pkg_sto.get_dependencies('a', 1)))
def test_dependencies_works_fine_with_indirect_cycle(self): pkgs = { 'a': self._new_pkg(['b']), 'b': self._new_pkg(['c']), 'c': self._new_pkg(['a']) } pkg_sto = storage.BasePkgStorage() pkg_sto._pkgs = pkgs self.assertEqual(['a', 'b', 'c'], sorted(pkg_sto.get_dependencies('a')))
def test_dependencies_return_direct_and_indirect_deps(self): pkgs = { 'a': self._new_pkg(['b']), 'b': self._new_pkg(['c', 'd']), 'c': self._new_pkg(), 'd': self._new_pkg(), 'e': self._new_pkg(), } pkg_sto = storage.BasePkgStorage() pkg_sto._pkgs = pkgs self.assertEqual(['b', 'c', 'd'], sorted(pkg_sto.get_dependencies('a')))
def test_dependencies_ok_with_filter_fun(self): pkgs = { 'a': self._new_pkg(['b']), 'b': self._new_pkg(['c']), 'c': self._new_pkg() } filter_fun = lambda pkg_id: pkg_id != 'c' pkg_sto = storage.BasePkgStorage() pkg_sto._pkgs = pkgs self.assertEqual(['b'], sorted( pkg_sto.get_dependencies('a', filter_fun=filter_fun)))
def test_dependencies_multiple_depths_consider_shortest_depth(self): pkgs = { 'a': self._new_pkg(['c']), 'b': self._new_pkg(['d']), 'c': self._new_pkg(['d']), 'd': self._new_pkg() } pkg_sto = storage.BasePkgStorage() pkg_sto._pkgs = pkgs self.assertEqual(['c', 'd'], sorted( pkg_sto.get_dependencies_many(['a', 'b'], maxdepth=1)))
def test_dependencies_missing_raise_error_when_not_ignore(self): pkgs = {'a': self._new_pkg(['b'])} pkg_sto = storage.BasePkgStorage() pkg_sto._pkgs = pkgs self.assertRaises(Exception, pkg_sto.get_dependencies, 'a')
def test_dependencies_with_maxdepth_0_return_empty_set(self): pkgs = {'a': self._new_pkg(['b']), 'b': self._new_pkg()} pkg_sto = storage.BasePkgStorage() pkg_sto._pkgs = pkgs self.assertEqual(set(), pkg_sto.get_dependencies('a', 0))