| 1 |
from unittest.mock import patch |
| 2 |
from pytest import raises |
| 3 |
import unittest.mock as mock |
| 4 |
|
| 5 |
from kiwi.repository import Repository |
| 6 |
from kiwi.exceptions import KiwiRepositorySetupError |
| 7 |
|
| 8 |
|
| 9 |
class TestRepository: |
| 10 |
def test_repository_manager_not_implemented(self): |
| 11 |
with raises(KiwiRepositorySetupError): |
| 12 |
Repository.new('root_bind', 'ms-manager') |
| 13 |
|
| 14 |
@patch('kiwi.repository.zypper.RepositoryZypper') |
| 15 |
def test_repository_zypper(self, mock_manager): |
| 16 |
root_bind = mock.Mock() |
| 17 |
Repository.new(root_bind, 'zypper') |
| 18 |
mock_manager.assert_called_once_with(root_bind, None) |
| 19 |
|
| 20 |
@patch('kiwi.repository.dnf.RepositoryDnf') |
| 21 |
def test_repository_dnf(self, mock_manager): |
| 22 |
root_bind = mock.Mock() |
| 23 |
Repository.new(root_bind, 'dnf') |
| 24 |
mock_manager.assert_called_once_with(root_bind, None) |
| 25 |
|
| 26 |
@patch('kiwi.repository.dnf4.RepositoryDnf4') |
| 27 |
def test_repository_dnf4(self, mock_manager): |
| 28 |
root_bind = mock.Mock() |
| 29 |
Repository.new(root_bind, 'dnf4') |
| 30 |
mock_manager.assert_called_once_with(root_bind, None) |
| 31 |
|
| 32 |
@patch('kiwi.repository.dnf5.RepositoryDnf5') |
| 33 |
def test_repository_dnf5(self, mock_manager): |
| 34 |
root_bind = mock.Mock() |
| 35 |
Repository.new(root_bind, 'dnf5') |
| 36 |
mock_manager.assert_called_once_with(root_bind, None) |
| 37 |
|
| 38 |
@patch('kiwi.repository.dnf4.RepositoryDnf4') |
| 39 |
def test_repository_microdnf(self, mock_manager): |
| 40 |
root_bind = mock.Mock() |
| 41 |
Repository.new(root_bind, 'microdnf') |
| 42 |
mock_manager.assert_called_once_with(root_bind, None) |
| 43 |
|
| 44 |
@patch('kiwi.repository.apt.RepositoryApt') |
| 45 |
def test_repository_apt(self, mock_manager): |
| 46 |
root_bind = mock.Mock() |
| 47 |
Repository.new(root_bind, 'apt') |
| 48 |
mock_manager.assert_called_once_with(root_bind, None) |
| 49 |
|
| 50 |
@patch('kiwi.repository.pacman.RepositoryPacman') |
| 51 |
def test_repository_pacman(self, mock_manager): |
| 52 |
root_bind = mock.Mock() |
| 53 |
Repository.new(root_bind, 'pacman') |
| 54 |
mock_manager.assert_called_once_with(root_bind, None) |