Beispiel #1
0
    def test_search(self):
        """
        Test searching for a package
        """

        # Test searching for an available and uninstalled package
        pkgin_out = [
            "somepkg-1.0          Some package description here",
            "",
            "=: package is installed and up-to-date",
            "<: package is installed but newer version is available",
            ">: installed package has a greater version than available package",
        ]

        pkgin__get_version_mock = MagicMock(return_value=["0", "9", "0"])
        pkgin__check_pkgin_mock = MagicMock(return_value="/opt/pkg/bin/pkgin")
        pkgin_search_cmd = MagicMock(return_value=os.linesep.join(pkgin_out))

        with patch("salt.modules.pkgin._get_version",
                   pkgin__get_version_mock), patch(
                       "salt.modules.pkgin._check_pkgin",
                       pkgin__check_pkgin_mock), patch.dict(
                           pkgin.__salt__, {"cmd.run": pkgin_search_cmd}):
            self.assertDictEqual(pkgin.search("somepkg"), {"somepkg": "1.0"})

        # Test searching for an available and installed package
        pkgin_out = [
            "somepkg-1.0 =          Some package description here",
            "",
            "=: package is installed and up-to-date",
            "<: package is installed but newer version is available",
            ">: installed package has a greater version than available package",
        ]

        pkgin_search_cmd = MagicMock(return_value=os.linesep.join(pkgin_out))

        with patch("salt.modules.pkgin._get_version",
                   pkgin__get_version_mock), patch(
                       "salt.modules.pkgin._check_pkgin",
                       pkgin__check_pkgin_mock), patch.dict(
                           pkgin.__salt__, {"cmd.run": pkgin_search_cmd}):
            self.assertDictEqual(pkgin.search("somepkg"), {"somepkg": "1.0"})
Beispiel #2
0
    def test_search(self):
        '''
        Test searching for a package
        '''

        # Test searching for an available and uninstalled package
        pkgin_out = [
            'somepkg-1.0          Some package description here', '',
            '=: package is installed and up-to-date',
            '<: package is installed but newer version is available',
            '>: installed package has a greater version than available package'
        ]

        pkgin__get_version_mock = MagicMock(return_value=['0', '9', '0'])
        pkgin__check_pkgin_mock = MagicMock(return_value='/opt/pkg/bin/pkgin')
        pkgin_search_cmd = MagicMock(return_value=os.linesep.join(pkgin_out))

        with patch('salt.modules.pkgin._get_version', pkgin__get_version_mock), \
             patch('salt.modules.pkgin._check_pkgin', pkgin__check_pkgin_mock), \
             patch.dict(pkgin.__salt__, {'cmd.run': pkgin_search_cmd}):
            self.assertDictEqual(pkgin.search('somepkg'), {'somepkg': '1.0'})

        # Test searching for an available and installed package
        pkgin_out = [
            'somepkg-1.0 =          Some package description here', '',
            '=: package is installed and up-to-date',
            '<: package is installed but newer version is available',
            '>: installed package has a greater version than available package'
        ]

        pkgin_search_cmd = MagicMock(return_value=os.linesep.join(pkgin_out))

        with patch('salt.modules.pkgin._get_version', pkgin__get_version_mock), \
             patch('salt.modules.pkgin._check_pkgin', pkgin__check_pkgin_mock), \
             patch.dict(pkgin.__salt__, {'cmd.run': pkgin_search_cmd}):
            self.assertDictEqual(pkgin.search('somepkg'), {'somepkg': '1.0'})