"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/unit/meta/test_package_repository.py" between
snapcraft-4.5.1.tar.gz and snapcraft-4.5.2.tar.gz

About: Snapcraft is a build and packaging tool that makes it easy to incorporate components from different sources and build technologies or solutions.

test_package_repository.py  (snapcraft-4.5.1):test_package_repository.py  (snapcraft-4.5.2)
skipping to change at line 19 skipping to change at line 19
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import pytest import pytest
from snapcraft.internal import repo
from snapcraft.internal.meta import errors from snapcraft.internal.meta import errors
from snapcraft.internal.meta.package_repository import ( from snapcraft.internal.meta.package_repository import (
PackageRepository, PackageRepository,
PackageRepositoryApt, PackageRepositoryApt,
PackageRepositoryAptPpa, PackageRepositoryAptPpa,
) )
from tests.unit import mock
@pytest.fixture(autouse=True)
def mock_repo():
with mock.patch(
"snapcraft.internal.meta.package_repository.repo.Ubuntu", spec=repo.Ubun
tu
) as m:
yield m
def test_apt_name(): def test_apt_name():
repo = PackageRepositoryApt( repo = PackageRepositoryApt(
architectures=["amd64", "i386"], architectures=["amd64", "i386"],
components=["main", "multiverse"], components=["main", "multiverse"],
formats=["deb", "deb-src"], formats=["deb", "deb-src"],
key_id="A" * 40, key_id="A" * 40,
key_server="keyserver.ubuntu.com", key_server="keyserver.ubuntu.com",
suites=["xenial", "xenial-updates"], suites=["xenial", "xenial-updates"],
url="http://archive.ubuntu.com/ubuntu", url="http://archive.ubuntu.com/ubuntu",
skipping to change at line 166 skipping to change at line 157
url="http://archive.ubuntu.com/ubuntu", url="http://archive.ubuntu.com/ubuntu",
) )
assert exc_info.value.brief == "Invalid suite 'my-suite/'." assert exc_info.value.brief == "Invalid suite 'my-suite/'."
assert exc_info.value.details == "Suites must not end with a '/'." assert exc_info.value.details == "Suites must not end with a '/'."
assert ( assert (
exc_info.value.resolution exc_info.value.resolution
== "Verify the repository configuration and remove the trailing '/ from suites or use the 'path' property to define a path." == "Verify the repository configuration and remove the trailing '/ from suites or use the 'path' property to define a path."
) )
def test_apt_install(mock_repo, tmp_path):
repo = PackageRepositoryApt(
architectures=["amd64", "i386"],
components=["main", "multiverse"],
formats=["deb", "deb-src"],
key_id="A" * 40,
key_server="xkeyserver.ubuntu.com",
name="some-name",
suites=["xenial", "xenial-updates"],
url="http://archive.ubuntu.com/ubuntu",
)
repo.install()
assert mock_repo.mock_calls == [
mock.call.install_sources(
architectures=["amd64", "i386"],
components=["main", "multiverse"],
formats=["deb", "deb-src"],
name="some-name",
suites=["xenial", "xenial-updates"],
url="http://archive.ubuntu.com/ubuntu",
),
]
def test_apt_install_with_path(mock_repo, tmp_path):
repo = PackageRepositoryApt(
key_id="A" * 40, path="x", url="http://archive.ubuntu.com/ubuntu",
)
repo.install()
assert mock_repo.mock_calls == [
mock.call.install_sources(
architectures=None,
components=None,
formats=None,
name="http_archive_ubuntu_com_ubuntu",
suites=["x/"],
url="http://archive.ubuntu.com/ubuntu",
),
]
def test_apt_install_implied_path(mock_repo, tmp_path):
repo = PackageRepositoryApt(
key_id="A" * 40, url="http://archive.ubuntu.com/ubuntu",
)
repo.install()
assert mock_repo.mock_calls == [
mock.call.install_sources(
architectures=None,
components=None,
formats=None,
name="http_archive_ubuntu_com_ubuntu",
suites=["/"],
url="http://archive.ubuntu.com/ubuntu",
),
]
def test_apt_marshal(): def test_apt_marshal():
repo = PackageRepositoryApt( repo = PackageRepositoryApt(
architectures=["amd64", "i386"], architectures=["amd64", "i386"],
components=["main", "multiverse"], components=["main", "multiverse"],
formats=["deb", "deb-src"], formats=["deb", "deb-src"],
key_id="A" * 40, key_id="A" * 40,
key_server="xkeyserver.ubuntu.com", key_server="xkeyserver.ubuntu.com",
name="test-name", name="test-name",
suites=["xenial", "xenial-updates"], suites=["xenial", "xenial-updates"],
url="http://archive.ubuntu.com/ubuntu", url="http://archive.ubuntu.com/ubuntu",
skipping to change at line 379 skipping to change at line 309
assert ( assert (
exc_info.value.brief exc_info.value.brief
== "Found unsupported package repository properties 'test'." == "Found unsupported package repository properties 'test'."
) )
assert exc_info.value.details is None assert exc_info.value.details is None
assert ( assert (
exc_info.value.resolution exc_info.value.resolution
== "Verify repository configuration and ensure that it is correct." == "Verify repository configuration and ensure that it is correct."
) )
def test_ppa_install(mock_repo):
repo = PackageRepositoryAptPpa(ppa="test/ppa")
repo.install()
assert mock_repo.mock_calls == [mock.call.install_ppa(ppa="test/ppa")]
def test_unmarshal_package_repositories_list_none(): def test_unmarshal_package_repositories_list_none():
assert PackageRepository.unmarshal_package_repositories(None) == list() assert PackageRepository.unmarshal_package_repositories(None) == list()
def test_unmarshal_package_repositories_list_empty(): def test_unmarshal_package_repositories_list_empty():
assert PackageRepository.unmarshal_package_repositories(list()) == list() assert PackageRepository.unmarshal_package_repositories(list()) == list()
def test_unmarshal_package_repositories_list_ppa(): def test_unmarshal_package_repositories_list_ppa():
test_dict = {"type": "apt", "ppa": "test/foo"} test_dict = {"type": "apt", "ppa": "test/foo"}
test_list = [test_dict] test_list = [test_dict]
 End of changes. 4 change blocks. 
78 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)