From 447bbde5a4b67a5862ae1af5ef3565b5aaacc2cf Mon Sep 17 00:00:00 2001 From: Andreas Eknes Lie Date: Thu, 5 Dec 2024 14:46:33 +0100 Subject: [PATCH] Adds suggest deprecated symlink capability --- komodo/symlink/suggester/cli.py | 2 +- komodo/symlink/suggester/configuration.py | 2 +- tests/test_suggester.py | 66 ++++++++++++++++++++++- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/komodo/symlink/suggester/cli.py b/komodo/symlink/suggester/cli.py index 2d87b0f7..698c18e5 100755 --- a/komodo/symlink/suggester/cli.py +++ b/komodo/symlink/suggester/cli.py @@ -35,7 +35,7 @@ def _parse_args(): formatter_class=argparse.ArgumentDefaultsHelpFormatter, ) parser.add_argument("release", help="e.g. 2019.12.rc0-py38") - parser.add_argument("mode", help="stable,testing") + parser.add_argument("mode", help="stable,testing,deprecated") parser.add_argument("joburl", help="link to the job that triggered this") parser.add_argument("jobname", help="name of the job") parser.add_argument("--git-fork", help="git fork", default="equinor") diff --git a/komodo/symlink/suggester/configuration.py b/komodo/symlink/suggester/configuration.py index ecc40d11..5b9dd482 100644 --- a/komodo/symlink/suggester/configuration.py +++ b/komodo/symlink/suggester/configuration.py @@ -48,7 +48,7 @@ def update(self, release, mode, python_versions: List[str]): self.links[link] = release.month_alias() else: self.links[link] = repr(release) - elif mode == "stable": + elif mode == "stable" or mode == "deprecated": self.links[release.month_alias()] = repr(release) self.links[link] = release.month_alias() else: diff --git a/tests/test_suggester.py b/tests/test_suggester.py index 8796b05b..f9c34b52 100644 --- a/tests/test_suggester.py +++ b/tests/test_suggester.py @@ -233,6 +233,32 @@ def test_get_concrete_release(conf, link, concrete): "testing-py37": "2021.01-py37" } } +""", + ), + # suggest deprecated update after skipped month + ( + """{"links": { + "2020.11-py37": "2020.11.04-py37", + "2020.12-py37": "2020.12.rc2-py37", + "stable-py3": "stable-py37", + "stable-py37": "2020.11-py37", + "deprecated-py3": "deprecated-py37", + "deprecated-py37": "2020.12-py37" + }}""", + "2021.01.rc3-py37", + "deprecated", + "changed", + """{ + "links": { + "2020.11-py37": "2020.11.04-py37", + "2020.12-py37": "2020.12.rc2-py37", + "2021.01-py37": "2021.01.rc3-py37", + "deprecated-py3": "deprecated-py37", + "deprecated-py37": "2021.01-py37", + "stable-py3": "stable-py37", + "stable-py37": "2020.11-py37" + } +} """, ), ], @@ -255,13 +281,17 @@ def _mock_repo(sym_config): [ ("foo.json", "stable"), ("foo_azure.json", "stable"), + ("foo.json", "deprecated"), + ("foo.json", "testing") ], ) def test_suggest_symlink_configuration(symlink_file, mode): """Testing whether when updating symlink file the branch gets a corresponding name.""" config = """{"links": { "2050.02-py58": "2050.02.00-py58", -"stable-py58": "2050.02-py58" +"deprecated-py58": "2050.02-py58", +"stable-py58": "2050.02-py58", +"testing-py58": "2050.02-py58" }}""" repo = _mock_repo(config) @@ -288,7 +318,9 @@ def test_suggest_symlink_configuration(symlink_file, mode): """{ "links": { "2050.02-py58": "2050.02.01-py58", - "stable-py58": "2050.02-py58" + "deprecated-py58": "2050.02-py58", + "stable-py58": "2050.02-py58", + "testing-py58": "2050.02-py58" } } """, @@ -388,6 +420,36 @@ def test_suggest_symlink_multi_configuration(): "testing-py38": "2001.12.rc0-py38" } } +""", + ), + # testing deprecated promotion from previous release + ( + """{"links": { + "2001.11-py38": "2001.11.00-py38", + "2001.11-py311": "2001.11.00-py311", + "deprecated-py38": "2001.11.rc0-py38", + "deprecated-py311": "2001.11.rc0-py311", + "stable-py38" : "2001.11-py38", + "testing-py38": "2001.11.rc0-py38", + "stable-py311" : "2001.11-py311", + "testing-py311": "2001.11.rc0-py311"}}""", + "2001.12.rc0", + "deprecated", + "changed", + """{ + "links": { + "2001.11-py311": "2001.11.00-py311", + "2001.11-py38": "2001.11.00-py38", + "2001.12-py311": "2001.12.rc0-py311", + "2001.12-py38": "2001.12.rc0-py38", + "deprecated-py311": "2001.12-py311", + "deprecated-py38": "2001.12-py38", + "stable-py311": "2001.11-py311", + "stable-py38": "2001.11-py38", + "testing-py311": "2001.11.rc0-py311", + "testing-py38": "2001.11.rc0-py38" + } +} """, ), ],