Skip to content

Commit 56c7361

Browse files
authored
Colorize "extended support" column and re-order date columns (#191)
2 parents cab4e39 + a6add52 commit 56c7361

File tree

4 files changed

+89
-5
lines changed

4 files changed

+89
-5
lines changed

src/norwegianblue/__init__.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ def _colourify(data: list[dict], *, is_html: bool = False) -> list[dict]:
132132
six_months_from_now = now + relativedelta(months=+6)
133133

134134
for cycle in data:
135-
for property_ in ("support", "eol", "discontinued"):
135+
for property_ in ("discontinued", "support", "eol", "extendedSupport"):
136136
if property_ not in cycle:
137137
continue
138138

139139
# Handle Boolean
140140
if isinstance(cycle[property_], bool):
141-
if property_ == "support":
142-
colour = "green" if cycle["support"] else "red"
143-
else: # "eol" and "discontinued"
141+
if property_ in ("support", "extendedSupport"):
142+
colour = "green" if cycle[property_] else "red"
143+
else: # "discontinued" or "eol"
144144
colour = "red" if cycle[property_] else "green"
145145

146146
cycle[property_] = _apply_colour(
@@ -184,6 +184,8 @@ def _tabulate(
184184
row["release"] = row.pop("releaseDate")
185185
if "latestReleaseDate" in row:
186186
row["latest release"] = row.pop("latestReleaseDate")
187+
if "extendedSupport" in row:
188+
row["extended support"] = row.pop("extendedSupport")
187189

188190
headers = sorted(set().union(*(d.keys() for d in data)))
189191

@@ -200,9 +202,10 @@ def _tabulate(
200202
"release",
201203
"latest",
202204
"latest release",
203-
"support",
204205
"discontinued",
206+
"support",
205207
"eol",
208+
"extended support",
206209
):
207210
if preferred in headers:
208211
new_headers.append(preferred)

tests/data/expected_output.py

+11
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,14 @@
225225
| 3.3 | 2012-09-29 | 3.3.7 | 2017-09-19 | 2017-09-29 |
226226
| 2.7 | 2010-07-03 | 2.7.18 | 2020-04-19 | 2020-01-01 |
227227
"""
228+
229+
EXPECTED_MD_RHEL = """
230+
| cycle | release | latest | latest release | support | eol | extended support |
231+
|:------|:----------:|:-------|:--------------:|:----------:|:----------:|:----------------:|
232+
| 9 LTS | 2022-05-17 | 9.3 | 2023-11-07 | 2027-05-31 | 2032-05-31 | 2035-05-31 |
233+
| 8 LTS | 2019-05-07 | 8.9 | 2023-11-14 | 2024-05-31 | 2029-05-31 | 2032-05-31 |
234+
| 7 LTS | 2013-12-11 | 7.9 | 2020-09-29 | 2019-08-06 | 2024-06-30 | 2028-06-30 |
235+
| 6 LTS | 2010-11-09 | 6.10 | 2018-06-19 | 2016-05-10 | 2020-11-30 | 2024-06-30 |
236+
| 5 LTS | 2007-03-15 | 5.11 | 2014-09-16 | 2013-01-08 | 2017-03-31 | 2020-11-30 |
237+
| 4 | 2005-02-15 | 4.9 | 2011-02-16 | 2009-03-31 | 2012-02-29 | 2017-03-31 |
238+
""" # noqa: E501

tests/data/sample_response.py

+65
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,71 @@
112112
]
113113
"""
114114

115+
SAMPLE_RESPONSE_JSON_RHEL = """
116+
[
117+
{
118+
"cycle": "9",
119+
"releaseDate": "2022-05-17",
120+
"support": "2027-05-31",
121+
"eol": "2032-05-31",
122+
"lts": "2032-05-31",
123+
"extendedSupport": "2035-05-31",
124+
"latest": "9.3",
125+
"latestReleaseDate": "2023-11-07"
126+
},
127+
{
128+
"cycle": "8",
129+
"releaseDate": "2019-05-07",
130+
"support": "2024-05-31",
131+
"eol": "2029-05-31",
132+
"lts": "2029-05-31",
133+
"extendedSupport": "2032-05-31",
134+
"latest": "8.9",
135+
"latestReleaseDate": "2023-11-14"
136+
},
137+
{
138+
"cycle": "7",
139+
"releaseDate": "2013-12-11",
140+
"support": "2019-08-06",
141+
"eol": "2024-06-30",
142+
"lts": "2024-06-30",
143+
"extendedSupport": "2028-06-30",
144+
"latest": "7.9",
145+
"latestReleaseDate": "2020-09-29"
146+
},
147+
{
148+
"cycle": "6",
149+
"releaseDate": "2010-11-09",
150+
"support": "2016-05-10",
151+
"eol": "2020-11-30",
152+
"lts": "2020-11-30",
153+
"extendedSupport": "2024-06-30",
154+
"latest": "6.10",
155+
"latestReleaseDate": "2018-06-19"
156+
},
157+
{
158+
"cycle": "5",
159+
"releaseDate": "2007-03-15",
160+
"support": "2013-01-08",
161+
"eol": "2017-03-31",
162+
"lts": "2017-03-31",
163+
"extendedSupport": "2020-11-30",
164+
"latest": "5.11",
165+
"latestReleaseDate": "2014-09-16"
166+
},
167+
{
168+
"cycle": "4",
169+
"releaseDate": "2005-02-15",
170+
"support": "2009-03-31",
171+
"eol": "2012-02-29",
172+
"extendedSupport": "2017-03-31",
173+
"latest": "4.9",
174+
"latestReleaseDate": "2011-02-16",
175+
"lts": false
176+
}
177+
]
178+
"""
179+
115180
SAMPLE_RESPONSE_JSON_UBUNTU = """
116181
[
117182
{

tests/test_norwegianblue.py

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
EXPECTED_MD_COLOUR,
2424
EXPECTED_MD_LOG4J,
2525
EXPECTED_MD_PYTHON,
26+
EXPECTED_MD_RHEL,
2627
EXPECTED_PRETTY,
2728
EXPECTED_PRETTY_WITH_TITLE,
2829
EXPECTED_RST,
@@ -32,6 +33,7 @@
3233
SAMPLE_RESPONSE_ALL_JSON,
3334
SAMPLE_RESPONSE_JSON_LOG4J,
3435
SAMPLE_RESPONSE_JSON_PYTHON,
36+
SAMPLE_RESPONSE_JSON_RHEL,
3537
SAMPLE_RESPONSE_JSON_UBUNTU,
3638
)
3739

@@ -110,6 +112,9 @@ def test_norwegianblue_formats(
110112
pytest.param(
111113
"python", SAMPLE_RESPONSE_JSON_PYTHON, EXPECTED_MD_PYTHON, id="python"
112114
),
115+
pytest.param(
116+
"rhel", SAMPLE_RESPONSE_JSON_RHEL, EXPECTED_MD_RHEL, id="rhel"
117+
),
113118
],
114119
)
115120
def test_norwegianblue_products(

0 commit comments

Comments
 (0)