[osinfo-db PATCH 2/2] tests: add a new test for dates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)
+
+
+@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

_______________________________________________
Libosinfo mailing list
Libosinfo@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libosinfo



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux