def test_if_origin_does_not_match_then_blacklist_is_not_checked(self): origin = Mock() origin.origin = "some-other-origin" pkg = Mock() pkg.name = "postgresql" pkg.is_upgradable = True pkg.candidate = Mock() pkg.candidate.policy_priority = 500 pkg.candidate.origins = [origin] pkg.versions = [pkg.candidate] cache = Mock() cache.__iter__ = Mock(return_value=iter([pkg])) options = Mock() pkgs_to_upgrade, pkgs_kept_back = \ calculate_upgradable_pkgs(cache, options, ["o=allowed-origin"], ["postgresql"], []) self.assertListEqual([], pkgs_to_upgrade) self.assertEqual(0, len(pkgs_kept_back))
def test_if_pkg_candidate_is_unavailable_then_pkg_is_not_considered(self): origin = Mock() origin.origin = 'allowed-origin' pkg = Mock() pkg.name = 'findutils' pkg.is_upgradable = False pkg.is_installed = True pkg.installed = Mock() pkg.installed.policy_priority = -1 pkg.installed.origins = [origin] pkg.installed.version = '1:0.1' pkg.candidate = None pkg.versions = [pkg.installed] cache = Mock() cache.__iter__ = Mock(return_value=iter([pkg])) options = Mock() pkgs_to_upgrade, pkgs_kept_back = \ calculate_upgradable_pkgs( cache, options, ['o=allowed-origin'], ['findutils'], []) self.assertListEqual([], pkgs_to_upgrade) self.assertEqual(0, len(pkgs_kept_back))
def test_rewind_cache(self): """ Test that rewinding the cache works correctly, debian #743594 """ options = MockOptions() blacklist = [] whitelist = [] to_upgrade, kept_back = unattended_upgrade.calculate_upgradable_pkgs( self.cache, options, self.allowed_origins, blacklist, whitelist) self.assertEqual(to_upgrade, [self.cache["test-package"]]) self.assertEqual(kept_back, ["z-package"])
def test_rewind_cache(self): """ Test that rewinding the cache works correctly, debian #743594 """ options = MockOptions() to_upgrade = unattended_upgrade.calculate_upgradable_pkgs( self.cache, options) self.assertEqual(to_upgrade, [ self.cache[p] for p in ["test-package", "test2-package", "test3-package"] ]) unattended_upgrade.rewind_cache(self.cache, to_upgrade) self.assertEqual(self.cache['test-package'].candidate.version, "2.0")
def test_rewind_cache(self): """ Test that rewinding the cache works correctly, debian #743594 """ options = MockOptions() blacklist = [] whitelist = [] to_upgrade, kept_back = unattended_upgrade.calculate_upgradable_pkgs( self.cache, options, self.allowed_origins, blacklist, whitelist) self.assertEqual(to_upgrade, [self.cache[p] for p in ["test-package", "test2-package", "test3-package"]]) self.assertEqual(kept_back["Ubuntu lucid-security"], {"z-package"}) unattended_upgrade.rewind_cache(self.cache, to_upgrade) self.assertEqual(self.cache['test-package'].candidate.version, "2.0")
def test_if_origin_does_not_match_then_blacklist_is_not_checked(self): origin = Mock() origin.origin = "some-other-origin" pkg = Mock() pkg.name = "postgresql" pkg.is_upgradable = True pkg.candidate = Mock() pkg.candidate.origins = [origin] options = Mock() pkgs_to_upgrade, pkgs_kept_back = \ calculate_upgradable_pkgs([pkg], options, ["o=allowed-origin"], ["postgresql"], []) self.assertListEqual([], pkgs_to_upgrade) self.assertListEqual([], pkgs_kept_back)