def test_latest_releases_keep_stable(self) -> None: mock_config(self.config_contents) mirror = Mirror(Path("."), Master(url="https://foo.bar.com")) pkg = Package("foo", 1, mirror) pkg._metadata = { "info": { "name": "foo", "version": "2.0.0" }, # stable version "releases": { "1.0.0": {}, "1.1.0": {}, "1.1.1": {}, "1.1.2": {}, "1.1.3": {}, "2.0.0": {}, # <= stable version, keep it "2.0.1b1": {}, "2.0.1b2": {}, # <= most recent, keep it }, } pkg._filter_all_releases(mirror.filters.filter_release_plugins()) assert pkg.releases == {"2.0.1b2": {}, "2.0.0": {}}
def test__filter__matches__release(self) -> None: mock_config("""\ [plugins] enabled = allowlist_release [whitelist] packages = foo==1.2.0 """) mirror = Mirror(Path("."), Master(url="https://foo.bar.com")) pkg = Package("foo", 1, mirror) pkg._metadata = { "info": { "name": "foo" }, "releases": { "1.2.0": {}, "1.2.1": {} }, } pkg._filter_all_releases(mirror.filters.filter_release_plugins()) self.assertEqual(pkg.releases, {"1.2.0": {}})
def test_latest_releases_uninitialized(self) -> None: mock_config(self.config_contents) mirror = Mirror(Path("."), Master(url="https://foo.bar.com")) pkg = Package("foo", 1, mirror) pkg._metadata = { "info": { "name": "foo", "version": "2.0.0" }, "releases": { "1.0.0": {}, "1.1.0": {}, "1.1.1": {}, "1.1.2": {}, "1.1.3": {}, "2.0.0": {}, }, } pkg._filter_all_releases(mirror.filters.filter_release_plugins()) assert pkg.releases == { "1.0.0": {}, "1.1.0": {}, "1.1.1": {}, "1.1.2": {}, "1.1.3": {}, "2.0.0": {}, }
def test_plugin_check_match(self) -> None: mock_config(self.config_contents) mirror = Mirror(Path("."), Master(url="https://foo.bar.com")) pkg = Package("foo", 1, mirror) pkg._metadata = { "info": {"name": "foo", "version": "foo-1.2.0"}, "releases": {"foo-1.2.0rc2": {}, "foo-1.2.0": {}, "foo-1.2.0alpha2": {}}, } pkg._filter_all_releases(mirror.filters.filter_release_plugins()) assert pkg.releases == {"foo-1.2.0": {}}