"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/repositories/test_pool.py" between
poetry-1.1.15.tar.gz and poetry-1.2.0.tar.gz

About: Poetry is a tool for dependency management and packaging in Python.

test_pool.py  (poetry-1.1.15):test_pool.py  (poetry-1.2.0)
from __future__ import annotations
import pytest import pytest
from poetry.core.semver.version import Version
from poetry.repositories import Pool from poetry.repositories import Pool
from poetry.repositories import Repository from poetry.repositories import Repository
from poetry.repositories.exceptions import PackageNotFound from poetry.repositories.exceptions import PackageNotFound
from poetry.repositories.legacy_repository import LegacyRepository from poetry.repositories.legacy_repository import LegacyRepository
def test_pool_raises_package_not_found_when_no_package_is_found(): def test_pool_raises_package_not_found_when_no_package_is_found() -> None:
pool = Pool() pool = Pool()
pool.add_repository(Repository()) pool.add_repository(Repository("repo"))
with pytest.raises(PackageNotFound): with pytest.raises(PackageNotFound):
pool.package("foo", "1.0.0") pool.package("foo", Version.parse("1.0.0"))
def test_pool(): def test_pool():
pool = Pool() pool = Pool()
assert 0 == len(pool.repositories) assert len(pool.repositories) == 0
assert not pool.has_default() assert not pool.has_default()
def test_pool_with_initial_repositories(): def test_pool_with_initial_repositories():
repo = Repository() repo = Repository("repo")
pool = Pool([repo]) pool = Pool([repo])
assert 1 == len(pool.repositories) assert len(pool.repositories) == 1
assert not pool.has_default() assert not pool.has_default()
def test_repository_no_repository(): def test_repository_no_repository():
pool = Pool() pool = Pool()
with pytest.raises(ValueError): with pytest.raises(ValueError):
pool.repository("foo") pool.repository("foo")
def test_repository_from_normal_pool(): def test_repository_from_normal_pool():
repo = LegacyRepository("foo", "https://foo.bar") repo = LegacyRepository("foo", "https://foo.bar")
skipping to change at line 65 skipping to change at line 69
pool.add_repository(repo1) pool.add_repository(repo1)
pool.add_repository(secondary, secondary=True) pool.add_repository(secondary, secondary=True)
pool.add_repository(repo2) pool.add_repository(repo2)
pool.add_repository(default, default=True) pool.add_repository(default, default=True)
assert pool.repository("secondary") is secondary assert pool.repository("secondary") is secondary
assert pool.repository("default") is default assert pool.repository("default") is default
assert pool.repository("foo") is repo1 assert pool.repository("foo") is repo1
assert pool.repository("bar") is repo2 assert pool.repository("bar") is repo2
assert pool.has_default() assert pool.has_default()
def test_remove_repository():
repo1 = LegacyRepository("foo", "https://foo.bar")
repo2 = LegacyRepository("bar", "https://bar.baz")
repo3 = LegacyRepository("baz", "https://baz.quux")
pool = Pool()
pool.add_repository(repo1)
pool.add_repository(repo2)
pool.add_repository(repo3)
pool.remove_repository("bar")
assert pool.repository("foo") is repo1
assert not pool.has_repository("bar")
assert pool.repository("baz") is repo3
def test_remove_default_repository():
default = LegacyRepository("default", "https://default.com")
repo1 = LegacyRepository("foo", "https://foo.bar")
repo2 = LegacyRepository("bar", "https://bar.baz")
new_default = LegacyRepository("new_default", "https://new.default.com")
pool = Pool()
pool.add_repository(repo1)
pool.add_repository(repo2)
pool.add_repository(default, default=True)
assert pool.has_default()
pool.remove_repository("default")
assert not pool.has_default()
pool.add_repository(new_default, default=True)
assert pool.has_default()
assert pool.repositories[0] is new_default
assert not pool.has_repository("default")
def test_repository_ordering():
default1 = LegacyRepository("default1", "https://default1.com")
default2 = LegacyRepository("default2", "https://default2.com")
primary1 = LegacyRepository("primary1", "https://primary1.com")
primary2 = LegacyRepository("primary2", "https://primary2.com")
primary3 = LegacyRepository("primary3", "https://primary3.com")
secondary1 = LegacyRepository("secondary1", "https://secondary1.com")
secondary2 = LegacyRepository("secondary2", "https://secondary2.com")
secondary3 = LegacyRepository("secondary3", "https://secondary3.com")
pool = Pool()
pool.add_repository(secondary1, secondary=True)
pool.add_repository(primary1)
pool.add_repository(default1, default=True)
pool.add_repository(primary2)
pool.add_repository(secondary2, secondary=True)
pool.remove_repository("primary2")
pool.remove_repository("secondary2")
pool.add_repository(primary3)
pool.add_repository(secondary3, secondary=True)
assert pool.repositories == [default1, primary1, primary3, secondary1, secon
dary3]
with pytest.raises(ValueError):
pool.add_repository(default2, default=True)
 End of changes. 9 change blocks. 
6 lines changed or deleted 10 lines changed or added

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