def test_parse_releases(infopl, alfred4): """Parse releases JSON""" dls = Download.from_releases(RELEASES_JSON) assert len(dls) == len(VALID_DOWNLOADS), "wrong no. of downloads" for i, dl in enumerate(dls): print(("dl=%r, x=%r" % (dl, VALID_DOWNLOADS[i]))) assert dl == VALID_DOWNLOADS[i], "different downloads"
def test_parse_releases(infopl, alfred4): """Parse releases JSON""" dls = Download.from_releases(RELEASES_JSON) assert len(dls) == len(VALID_DOWNLOADS), "wrong no. of downloads" for i, dl in enumerate(dls): print('dl=%r, x=%r' % (dl, VALID_DOWNLOADS[i])) assert dl == VALID_DOWNLOADS[i], "different downloads"
def test_latest_download(infopl): """Latest download for Alfred version.""" dls = Download.from_releases(RELEASES_JSON) tests = ( # downloads, alfred version, prereleases, wanted result ([], None, False, None), (dls, None, False, "9.0"), (dls, None, True, "10.0-beta"), (dls, "4", False, "9.0"), (dls, "4", True, "10.0-beta"), (dls, "3", False, "6.0"), (dls, "3", True, "10.0-beta"), ) for data, version, pre, wanted in tests: dl = update.latest_download(data, version, pre) if wanted is None: assert dl is None, "latest is not None" else: assert dl.version == Version(wanted), "unexpected version"
def test_latest_download(infopl): """Latest download for Alfred version.""" dls = Download.from_releases(RELEASES_JSON) tests = ( # downloads, alfred version, prereleases, wanted result ([], None, False, None), (dls, None, False, '9.0'), (dls, None, True, '10.0-beta'), (dls, '4', False, '9.0'), (dls, '4', True, '10.0-beta'), (dls, '3', False, '6.0'), (dls, '3', True, '10.0-beta'), ) for data, version, pre, wanted in tests: dl = update.latest_download(data, version, pre) if wanted is None: assert dl is None, "latest is not None" else: assert dl.version == Version(wanted), "unexpected version"