[Libosinfo] [osinfo-db PATCH 2/2] tests: add a new test for dates
Pino Toscano
ptoscano at redhat.com
Tue May 21 12:01:39 UTC 2019
For each OS, check two things:
- release-date/eol-date are actually valid dates; this is needed because
the schema just specifies the regex, and it cannot detect invalid
dates such as "2019-05-00" or 2019-05-40"
- if both release-date/eol-date are specified, eol-date must be later
than release-date
---
tests/test_dates.py | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 tests/test_dates.py
diff --git a/tests/test_dates.py b/tests/test_dates.py
new file mode 100644
index 0000000..60f70e6
--- /dev/null
+++ b/tests/test_dates.py
@@ -0,0 +1,22 @@
+# This work is licensed under the GNU GPLv2 or later.
+# See the COPYING file in the top-level directory.
+
+import datetime
+
+import pytest
+
+from . import util
+
+
+def _parse_date(date_string):
+ if not date_string:
+ return None
+ return datetime.date.fromisoformat(date_string)
+
+
+ at pytest.mark.parametrize('os', util.DataFiles.oses())
+def test_dates(os):
+ release_date = _parse_date(os.release_date)
+ eol_date = _parse_date(os.eol_date)
+ if release_date and eol_date:
+ assert release_date < eol_date
--
2.21.0
More information about the Libosinfo
mailing list