Exemple #1
0
def test_get_selections():
    """
    Test - View package state from the dpkg database.
    """
    selections = {"install": ["wget"]}
    mock = MagicMock(return_value="wget\t\t\t\t\t\tinstall")
    with patch.dict(aptpkg.__salt__, {"cmd.run_stdout": mock}):
        assert aptpkg.get_selections("wget") == selections
Exemple #2
0
 def test_get_selections(self):
     '''
     Test - View package state from the dpkg database.
     '''
     selections = {'install': ['wget']}
     mock = MagicMock(return_value='wget\t\t\t\t\t\tinstall')
     with patch.dict(aptpkg.__salt__, {'cmd.run_stdout': mock}):
         self.assertEqual(aptpkg.get_selections('wget'), selections)
Exemple #3
0
 def test_get_selections(self):
     '''
     Test - View package state from the dpkg database.
     '''
     selections = {'install': ['wget']}
     mock = MagicMock(return_value='wget\t\t\t\t\t\tinstall')
     with patch.dict(aptpkg.__salt__, {'cmd.run_stdout': mock}):
         self.assertEqual(aptpkg.get_selections('wget'), selections)
Exemple #4
0
    def test_add_repo_key_failed(self):
        """
        Test - Add a repo key using incomplete input data.
        '''
        with pytest.raises(SaltInvocationError) as ex:
            aptpkg.add_repo_key(keyserver='keyserver.ubuntu.com')
        assert ' No keyid or keyid too short for keyserver: keyserver.ubuntu.com' in str(ex)

    def test_get_repo_keys(self):
        """
        Test - List known repo key details.
        """
        mock = MagicMock(return_value={"retcode": 0, "stdout": APT_KEY_LIST})
        with patch.dict(aptpkg.__salt__, {"cmd.run_all": mock}):
            self.assertEqual(aptpkg.get_repo_keys(), REPO_KEYS)

    @patch('salt.modules.aptpkg.__salt__', {'lowpkg.file_dict': MagicMock(return_value=LOWPKG_FILES)})
    def test_file_dict(self):
        """
        Test - List the files that belong to a package, grouped by package.
        '''
        assert aptpkg.file_dict('wget') == LOWPKG_FILES

    @patch('salt.modules.aptpkg.__salt__', {
        'lowpkg.file_list': MagicMock(return_value={'errors': LOWPKG_FILES['errors'],
                                                    'files': LOWPKG_FILES['packages']['wget']})})
    def test_file_list(self):
        '''
        Test 'file_list' function, which is just an alias to the lowpkg 'file_list'

        '''
        assert aptpkg.file_list('wget') == aptpkg.__salt__['lowpkg.file_list']()

    @patch('salt.modules.aptpkg.__salt__', {'cmd.run_stdout': MagicMock(return_value='wget\t\t\t\t\t\tinstall')})
    def test_get_selections(self):
        """
        Test - View package state from the dpkg database.
        '''
        assert aptpkg.get_selections('wget') == {'install': ['wget']}
Exemple #5
0
 def test_get_selections(self):
     '''
     Test - View package state from the dpkg database.
     '''
     assert aptpkg.get_selections('wget') == {'install': ['wget']}