def test_get_next_version_PATCH(self, u, http): """Test next patch version.""" http({ RJSON: gen_releases([(MAJOR, MINOR, PATCH), (MAJOR, MINOR, PATCH + 1)]) }) ver = u.get_next_version(version=U.UCS_Version((MAJOR, MINOR, PATCH))) assert U.UCS_Version((MAJOR, MINOR, PATCH + 1)) == ver
def test_get_next_version_MINOR(self, u, http): """Test next minor version.""" http({ RJSON: gen_releases([(MAJOR, MINOR, PATCH), (MAJOR, MINOR + 1, 0)]) }) ver = u.get_next_version(version=U.UCS_Version((MAJOR, MINOR, PATCH))) assert U.UCS_Version((MAJOR, MINOR + 1, 0)) == ver
def test_release_update_temporary_sources_list(self, ucr, u, http): """Test temporary sources list for update with one enabled component.""" ucr({ 'repository/online/component/a': 'yes', 'repository/online/component/b': 'no', }) http({ '%d.%d/maintained/component/%s/%s/Packages.gz' % (MAJOR, MINOR + 1, 'a', 'all'): DATA, '%d.%d/maintained/component/%s/%s/Packages.gz' % (MAJOR, MINOR + 1, 'a', ARCH): DATA, '%d.%d/maintained/component/%s/%s/Packages.gz' % (MAJOR, MINOR + 1, 'b', 'all'): DATA, '%d.%d/maintained/component/%s/%s/Packages.gz' % (MAJOR, MINOR + 1, 'b', ARCH): DATA, RJSON: gen_releases([(MAJOR, MINOR, PATCH), (MAJOR, MINOR + 1, 0)]) }) tmp = u.release_update_temporary_sources_list( U.UCS_Version((MAJOR, MINOR + 1, 0))) assert { 'deb https://updates.software-univention.de/ ucs%d%d%d main' % ( MAJOR, MINOR + 1, 0, ), 'deb https://updates.software-univention.de/%d.%d/maintained/component/ %s/%s/' % (MAJOR, MINOR + 1, 'a', 'all'), 'deb https://updates.software-univention.de/%d.%d/maintained/component/ %s/%s/' % (MAJOR, MINOR + 1, 'a', ARCH), } == set(tmp)
def test__get_component_version_empty(self, ucr, u, http): """Test getting component empty versions in range from MAJOR.MINOR-PATCH.""" ucr({'repository/online/component/a/version': ''}) http({ RJSON: gen_releases([(MAJOR, MINOR, 0)]), }) ver = U.UCS_Version((MAJOR, MINOR, 0)) # component.erratalevel! comp_ver = u.component('a')._versions(start=ver, end=ver) assert {ver} == set(comp_ver)
def test_release_update_available_MINOR(self, u, http): """Test next minor update.""" NEXT_u = U.UCS_Version((MAJOR, MINOR + 1, 0)) http({ RJSON: gen_releases([(MAJOR, MINOR, PATCH), (MAJOR, MINOR + 1, 0)]) }) next_u = u.release_update_available() assert NEXT_u == next_u
def test_release_update_available_PATCH(self, u, http): """Test next patch-level update.""" NEXT_u = U.UCS_Version((MAJOR, MINOR, PATCH + 1)) http({ RJSON: gen_releases([(MAJOR, MINOR, PATCH), (MAJOR, MINOR, PATCH + 1)]) }) next_u = u.release_update_available() assert NEXT_u == next_u
def test__get_component_version_short(self, ucr, u, http): """Test getting component versions in range from MAJOR.MINOR.""" ucr({ 'repository/online/component/a/version': '%d.%d' % (MAJOR, MINOR) }) http({ RJSON: gen_releases([(MAJOR, MINOR, PATCH)]), }) ver = U.UCS_Version((MAJOR, MINOR, 0)) comp_ver = u.component('a')._versions(None, None) assert {ver} == set(comp_ver)
def test_get_releases(self, u, http): http({ RJSON: gen_releases([(MAJOR, minor, patch) for minor in range(3) for patch in range(3)]), }) expected = [(U.UCS_Version((MAJOR, 1, patch)), dict(major=MAJOR, minor=1, patchlevel=patch, status="maintained")) for patch in range(3)] found = list(u.get_releases(start=expected[0][0], end=expected[-1][0])) assert expected == found
def test_get_component_repositories_NOARCH(self, ucr, http, u): """Test component repositories without architecture sub directories.""" ucr({ 'repository/online/component/a': 'yes', 'repository/online/component/a/layout': 'flat', }) http({ '%d.%d/maintained/component/a/Packages.gz' % (MAJOR, MINOR): DATA, RJSON: gen_releases(patches=[PATCH, PATCH + 1]), }) ver = U.UCS_Version((MAJOR, MINOR, PATCH)) a_repo = u.component('a').repositories(ver, ver) assert { 'deb https://updates.software-univention.de/%d.%d/maintained/component/a/ ./' % (MAJOR, MINOR), } == set(a_repo)
def test_get_all_available_release_updates(self, ucr, u, http): """Test next updates until blocked by missing current component.""" ucr({ 'repository/online/component/a': 'yes', 'repository/online/component/a/version': 'current', }) http({ RJSON: gen_releases([(MAJOR, MINOR, PATCH), (MAJOR, MINOR + 1, 0), (MAJOR + 1, 0, 0)]), '/%d.%d/maintained/component/%s/all/Packages.gz' % (MAJOR, MINOR + 1, 'a'): DATA, '/%d.%d/maintained/component/%s/amd64/Packages.gz' % (MAJOR, MINOR + 1, 'a'): DATA, }) versions, components = u.get_all_available_release_updates() assert [U.UCS_Version((MAJOR, MINOR + 1, 0))] == versions assert {'a'} == components
def test_get_next_version(self, u): """Test no next version.""" ver = u.get_next_version(version=U.UCS_Version((MAJOR, MINOR, PATCH))) assert ver is None
def test_current_version(self, u): """Test current version property.""" ver = u.current_version assert isinstance(ver, U.UCS_Version) assert U.UCS_Version((3, 0, 1)) == ver