@@ -0,0 +1,3195 @@
+'''%0Atests for pkg state%0A'''%0A%0A# Import Salt Testing libs%0Afrom salttesting import skipIf%0Afrom salttesting.helpers import (%0A    destructiveTest,%0A    ensure_in_syspath,%0A    requires_system_grains,%0A    requires_salt_modules%0A)%0Aensure_in_syspath('../../')%0A%0A# Import salt libs%0Aimport integration%0Aimport salt.utils%0A%0A_PKG_TARGETS = %7B%0A    'Arch': %5B'bzr', 'finch'%5D,%0A    'Debian': %5B'bzr', 'finch'%5D,%0A    'RedHat': %5B'bzr', 'finch'%5D,%0A    'FreeBSD': %5B'aalib', 'pth'%5D,%0A    'Suse': %5B'aalib', 'finch'%5D%0A%7D%0A%0A%0A@requires_salt_modules('pkg.latest_version')%0A@requires_salt_modules('pkg.version')%0Aclass PkgTest(integration.ModuleCase,%0A              integration.SaltReturnAssertsMixIn):%0A    '''%0A    pkg.installed state tests%0A    '''%0A    @destructiveTest%0A    @skipIf(salt.utils.is_windows(), 'minion is windows')%0A    @requires_system_grains%0A    def test_pkg_installed(self, grains=None):%0A        '''%0A        This is a destructive test as it installs and then removes a package%0A        '''%0A        os_family = grains.get('os_family', '')%0A        pkg_targets = _PKG_TARGETS.get(os_family, %5B%5D)%0A%0A        # Make sure that we have targets that match the os_family. If this%0A        # fails then the _PKG_TARGETS dict above needs to have an entry added,%0A        # with two packages that are not installed before these tests are run%0A        self.assertTrue(pkg_targets)%0A%0A        target = pkg_targets%5B0%5D%0A        version = self.run_function('pkg.version', %5Btarget%5D)%0A%0A        # If this assert fails, we need to find new targets, this test needs to%0A        # be able to test successful installation of packages, so this package%0A        # needs to not be installed before we run the states below%0A        self.assertFalse(version)%0A%0A        ret = self.run_state('pkg.installed', name=pkg_targets%5B0%5D)%0A        self.assertSaltTrueReturn(ret)%0A        ret = self.run_state('pkg.removed', name=pkg_targets%5B0%5D)%0A        self.assertSaltTrueReturn(ret)%0A%0A    @destructiveTest%0A    @skipIf(salt.utils.is_windows(), 'minion is windows')%0A    @requires_system_grains%0A    def test_pkg_installed_multipkg(self, grains=None):%0A        '''%0A        This is a destructive test as it installs and then removes two packages%0A        '''%0A        os_family = grains.get('os_family', '')%0A        pkg_targets = _PKG_TARGETS.get(os_family, %5B%5D)%0A%0A        # Make sure that we have targets that match the os_family. If this%0A        # fails then the _PKG_TARGETS dict above needs to have an entry added,%0A        # with two packages that are not installed before these tests are run%0A        self.assertTrue(pkg_targets)%0A%0A        version = self.run_function('pkg.version', pkg_targets)%0A%0A        # If this assert fails, we need to find new targets, this test needs to%0A        # be able to test successful installation of packages, so these%0A        # packages need to not be installed before we run the states below%0A        self.assertFalse(any(version.values()))%0A%0A        ret = self.run_state('pkg.installed', name=None, pkgs=pkg_targets)%0A        self.assertSaltTrueReturn(ret)%0A        ret = self.run_state('pkg.removed', name=None, pkgs=pkg_targets)%0A        self.assertSaltTrueReturn(ret)%0A%0A%0Aif __name__ == '__main__':%0A    from integration import run_tests%0A    run_tests(PkgTest)%0A

Add pkg.installed tests