diff --git a/src/norwegianblue/__init__.py b/src/norwegianblue/__init__.py index e9a312a..63ecb95 100644 --- a/src/norwegianblue/__init__.py +++ b/src/norwegianblue/__init__.py @@ -132,15 +132,15 @@ def _colourify(data: list[dict], *, is_html: bool = False) -> list[dict]: six_months_from_now = now + relativedelta(months=+6) for cycle in data: - for property_ in ("support", "eol", "discontinued"): + for property_ in ("discontinued", "support", "eol", "extendedSupport"): if property_ not in cycle: continue # Handle Boolean if isinstance(cycle[property_], bool): - if property_ == "support": - colour = "green" if cycle["support"] else "red" - else: # "eol" and "discontinued" + if property_ in ("support", "extendedSupport"): + colour = "green" if cycle[property_] else "red" + else: # "discontinued" or "eol" colour = "red" if cycle[property_] else "green" cycle[property_] = _apply_colour( @@ -184,6 +184,8 @@ def _tabulate( row["release"] = row.pop("releaseDate") if "latestReleaseDate" in row: row["latest release"] = row.pop("latestReleaseDate") + if "extendedSupport" in row: + row["extended support"] = row.pop("extendedSupport") headers = sorted(set().union(*(d.keys() for d in data))) @@ -200,9 +202,10 @@ def _tabulate( "release", "latest", "latest release", - "support", "discontinued", + "support", "eol", + "extended support", ): if preferred in headers: new_headers.append(preferred) diff --git a/tests/data/expected_output.py b/tests/data/expected_output.py index 5d59486..9c5f081 100644 --- a/tests/data/expected_output.py +++ b/tests/data/expected_output.py @@ -225,3 +225,14 @@ | 3.3 | 2012-09-29 | 3.3.7 | 2017-09-19 | 2017-09-29 | | 2.7 | 2010-07-03 | 2.7.18 | 2020-04-19 | 2020-01-01 | """ + +EXPECTED_MD_RHEL = """ +| cycle | release | latest | latest release | support | eol | extended support | +|:------|:----------:|:-------|:--------------:|:----------:|:----------:|:----------------:| +| 9 LTS | 2022-05-17 | 9.3 | 2023-11-07 | 2027-05-31 | 2032-05-31 | 2035-05-31 | +| 8 LTS | 2019-05-07 | 8.9 | 2023-11-14 | 2024-05-31 | 2029-05-31 | 2032-05-31 | +| 7 LTS | 2013-12-11 | 7.9 | 2020-09-29 | 2019-08-06 | 2024-06-30 | 2028-06-30 | +| 6 LTS | 2010-11-09 | 6.10 | 2018-06-19 | 2016-05-10 | 2020-11-30 | 2024-06-30 | +| 5 LTS | 2007-03-15 | 5.11 | 2014-09-16 | 2013-01-08 | 2017-03-31 | 2020-11-30 | +| 4 | 2005-02-15 | 4.9 | 2011-02-16 | 2009-03-31 | 2012-02-29 | 2017-03-31 | +""" # noqa: E501 diff --git a/tests/data/sample_response.py b/tests/data/sample_response.py index a6e36c0..7ee8299 100644 --- a/tests/data/sample_response.py +++ b/tests/data/sample_response.py @@ -112,6 +112,71 @@ ] """ +SAMPLE_RESPONSE_JSON_RHEL = """ +[ + { + "cycle": "9", + "releaseDate": "2022-05-17", + "support": "2027-05-31", + "eol": "2032-05-31", + "lts": "2032-05-31", + "extendedSupport": "2035-05-31", + "latest": "9.3", + "latestReleaseDate": "2023-11-07" + }, + { + "cycle": "8", + "releaseDate": "2019-05-07", + "support": "2024-05-31", + "eol": "2029-05-31", + "lts": "2029-05-31", + "extendedSupport": "2032-05-31", + "latest": "8.9", + "latestReleaseDate": "2023-11-14" + }, + { + "cycle": "7", + "releaseDate": "2013-12-11", + "support": "2019-08-06", + "eol": "2024-06-30", + "lts": "2024-06-30", + "extendedSupport": "2028-06-30", + "latest": "7.9", + "latestReleaseDate": "2020-09-29" + }, + { + "cycle": "6", + "releaseDate": "2010-11-09", + "support": "2016-05-10", + "eol": "2020-11-30", + "lts": "2020-11-30", + "extendedSupport": "2024-06-30", + "latest": "6.10", + "latestReleaseDate": "2018-06-19" + }, + { + "cycle": "5", + "releaseDate": "2007-03-15", + "support": "2013-01-08", + "eol": "2017-03-31", + "lts": "2017-03-31", + "extendedSupport": "2020-11-30", + "latest": "5.11", + "latestReleaseDate": "2014-09-16" + }, + { + "cycle": "4", + "releaseDate": "2005-02-15", + "support": "2009-03-31", + "eol": "2012-02-29", + "extendedSupport": "2017-03-31", + "latest": "4.9", + "latestReleaseDate": "2011-02-16", + "lts": false + } +] +""" + SAMPLE_RESPONSE_JSON_UBUNTU = """ [ { diff --git a/tests/test_norwegianblue.py b/tests/test_norwegianblue.py index d319e20..c5bdd96 100644 --- a/tests/test_norwegianblue.py +++ b/tests/test_norwegianblue.py @@ -23,6 +23,7 @@ EXPECTED_MD_COLOUR, EXPECTED_MD_LOG4J, EXPECTED_MD_PYTHON, + EXPECTED_MD_RHEL, EXPECTED_PRETTY, EXPECTED_PRETTY_WITH_TITLE, EXPECTED_RST, @@ -32,6 +33,7 @@ SAMPLE_RESPONSE_ALL_JSON, SAMPLE_RESPONSE_JSON_LOG4J, SAMPLE_RESPONSE_JSON_PYTHON, + SAMPLE_RESPONSE_JSON_RHEL, SAMPLE_RESPONSE_JSON_UBUNTU, ) @@ -110,6 +112,9 @@ def test_norwegianblue_formats( pytest.param( "python", SAMPLE_RESPONSE_JSON_PYTHON, EXPECTED_MD_PYTHON, id="python" ), + pytest.param( + "rhel", SAMPLE_RESPONSE_JSON_RHEL, EXPECTED_MD_RHEL, id="rhel" + ), ], ) def test_norwegianblue_products(