"""Offline tests of check-eol-tables.py: python3 -m unittest discover -s scripts.""" from __future__ import annotations import datetime as dt import importlib.util import unittest from pathlib import Path SPEC = importlib.util.spec_from_file_location( "check_eol_tables", Path(__file__).with_name("check-eol-tables.py")) assert SPEC is not None and SPEC.loader is not None check = importlib.util.module_from_spec(SPEC) SPEC.loader.exec_module(check) TODAY = dt.date(2026, 10, 9) class CompareTests(unittest.TestCase): def test_yocto_new_release_and_changed_dates_are_listed(self) -> None: table = {"releases": [{"codename": "wrynose", "version": "6.0", "lts": True, "released": "2026-05-13", "end_of_life": "2030-04-30"}]} upstream: list[dict[str, object]] = [ {"cycle": "6.1", "codename": "Blacksail", "releaseDate": "2026-10-20", "eol": "2027-04-30"}, {"cycle": "6.0", "codename": "Wrynose", "lts": True, "releaseDate": "2026-05-13", "eol": "2030-05-31"}, ] found = check.compare_yocto(table, upstream) self.assertEqual(len(found), 2) self.assertIn("Blacksail (6.1): on endoflife.date", found[0]) self.assertIn("end of life is 2030-05-31 on endoflife.date, 2030-04-30", found[1]) same = [{**upstream[1], "eol": "2030-04-30"}] self.assertEqual(check.compare_yocto(table, same), []) def test_dotnet_monikers_map_to_endoflife_cycles(self) -> None: self.assertEqual(check.dotnet_cycle("net8.0"), ("dotnet", "8")) self.assertEqual(check.dotnet_cycle("netcoreapp3.1"), ("dotnet", "3.1")) self.assertEqual(check.dotnet_cycle("net462"), ("dotnetfx", "4.6.2")) self.assertEqual(check.dotnet_cycle("net35"), ("dotnetfx", "3.5-sp1")) self.assertIsNone(check.dotnet_cycle("net20")) table = {"frameworks": [{"moniker": "net8.0", "end_of_support": "2026-11-10", "product": ".NET 8"}]} upstream = {"dotnet": [{"cycle": "8", "eol": "2026-11-10"}, {"cycle": "11", "eol": "2029-11-13"}, {"cycle": "12", "eol": False}]} self.assertEqual(check.compare_dotnet(table, upstream), ["dotnet 11: end of support 2029-11-13 on endoflife.date, " "not in the table"]) def test_platform_floors_are_the_oldest_supported_release(self) -> None: table = {"android": {"oldest_patched_api": 29}, "ios": {"oldest_patched": "15.0"}} android = [{"cycle": "14", "apiVersion": "34", "eol": False}, {"cycle": "13", "apiVersion": "33", "eol": "2026-03-02"}] ios = [{"cycle": "16", "eol": False}, {"cycle": "15", "eol": False}, {"cycle": "14", "eol": "2021-10-26"}] found = check.compare_platforms(table, android, ios, TODAY) self.assertEqual(found, ["Android: the oldest release with security updates is " "API 34 on endoflife.date, API 29 in the table"]) def test_the_issue_is_updated_only_when_the_differences_change(self) -> None: body = check.issue_body({"yocto.json": ["a"], "dotnet.json": []}, TODAY) self.assertIn("### `yocto.json`", body) self.assertNotIn("dotnet.json", body) later = check.issue_body({"yocto.json": ["a"]}, dt.date(2026, 10, 16)) self.assertEqual(check.without_check_date(body), check.without_check_date(later)) if __name__ == "__main__": unittest.main()