Beispiel #1
0
 def test_refresh_db_failed(self):
     '''
     Test - Update the APT database using unreachable repositories.
     '''
     with pytest.raises(CommandExecutionError) as err:
         aptpkg.refresh_db(failhard=True)
     assert 'Error getting repos' in str(err)
     assert 'http://security.ubuntu.com trusty InRelease, http://security.ubuntu.com trusty Release.gpg' in str(err)
Beispiel #2
0
def revert_repo_file(tmp_path):
    try:
        repo_file = pathlib.Path("/etc") / "apt" / "sources.list"
        backup = tmp_path / "repo_backup"
        # make copy of repo file
        shutil.copy(str(repo_file), str(backup))
        yield
    finally:
        # revert repo file
        shutil.copy(str(backup), str(repo_file))
        aptpkg.refresh_db()
Beispiel #3
0
def test_refresh_db_failed(apt_q_update_error_var):
    """
    Test - Update the APT database using unreachable repositories.
    """
    kwargs = {"failhard": True}
    mock = MagicMock(return_value={"retcode": 0, "stdout": apt_q_update_error_var})
    with patch("salt.utils.pkg.clear_rtag", MagicMock()):
        with patch.dict(
            aptpkg.__salt__,
            {"cmd.run_all": mock, "config.get": MagicMock(return_value=False)},
        ):
            with pytest.raises(CommandExecutionError):
                aptpkg.refresh_db(**kwargs)
Beispiel #4
0
 def test_refresh_db(self):
     '''
     Test - Updates the APT database to latest packages based upon repositories.
     '''
     refresh_db = {
         'http://security.ubuntu.com trusty-security InRelease': True,
         'http://security.ubuntu.com trusty-security/main Sources': True,
         'http://security.ubuntu.com trusty-security/main Translation-en': None,
         'http://security.ubuntu.com trusty-security/main amd64 Packages': True,
         'http://security.ubuntu.com trusty-security/main i386 Packages': True
     }
     assert aptpkg.refresh_db() == refresh_db
Beispiel #5
0
 def test_refresh_db(self):
     '''
     Test - Updates the APT database to latest packages based upon repositories.
     '''
     refresh_db = {
         'http://security.ubuntu.com trusty-security InRelease': True,
         'http://security.ubuntu.com trusty-security/main Sources': True,
         'http://security.ubuntu.com trusty-security/main Translation-en':
         None,
         'http://security.ubuntu.com trusty-security/main amd64 Packages':
         True,
         'http://security.ubuntu.com trusty-security/main i386 Packages':
         True
     }
     mock = MagicMock(return_value={'retcode': 0, 'stdout': APT_Q_UPDATE})
     with patch.dict(aptpkg.__salt__, {'cmd.run_all': mock}):
         self.assertEqual(aptpkg.refresh_db(), refresh_db)
Beispiel #6
0
 def test_refresh_db(self):
     '''
     Test - Updates the APT database to latest packages based upon repositories.
     '''
     refresh_db = {
         'http://security.ubuntu.com trusty-security InRelease': True,
         'http://security.ubuntu.com trusty-security/main Sources': True,
         'http://security.ubuntu.com trusty-security/main Translation-en': None,
         'http://security.ubuntu.com trusty-security/main amd64 Packages': True,
         'http://security.ubuntu.com trusty-security/main i386 Packages': True
     }
     mock = MagicMock(return_value={
         'retcode': 0,
         'stdout': APT_Q_UPDATE
     })
     with patch.dict(aptpkg.__salt__, {'cmd.run_all': mock}):
         self.assertEqual(aptpkg.refresh_db(), refresh_db)
Beispiel #7
0
 def test_refresh_db(self):
     """
     Test - Updates the APT database to latest packages based upon repositories.
     """
     refresh_db = {
         "http://security.ubuntu.com trusty-security InRelease": True,
         "http://security.ubuntu.com trusty-security/main Sources": True,
         "http://security.ubuntu.com trusty-security/main Translation-en": None,
         "http://security.ubuntu.com trusty-security/main amd64 Packages": True,
         "http://security.ubuntu.com trusty-security/main i386 Packages": True,
     }
     mock = MagicMock(return_value={"retcode": 0, "stdout": APT_Q_UPDATE})
     with patch("salt.utils.pkg.clear_rtag", MagicMock()):
         with patch.dict(
             aptpkg.__salt__,
             {"cmd.run_all": mock, "config.get": MagicMock(return_value=False)},
         ):
             self.assertEqual(aptpkg.refresh_db(), refresh_db)