From 229a169952f16a77f1687c1f63f160ef0ac98b7d Mon Sep 17 00:00:00 2001 From: sneakocom <192013763+sneakocom@users.noreply.github.com> Date: Fri, 18 Sep 2026 01:39:20 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Add=20tests=20for=20timestamp=20?= =?UTF-8?q?validation=20edge=20cases?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- commit_message.txt | 5 +++++ tests/test_validate_program.py | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 commit_message.txt diff --git a/commit_message.txt b/commit_message.txt new file mode 100644 index 0000000..dee6a7d --- /dev/null +++ b/commit_message.txt @@ -0,0 +1,5 @@ +๐Ÿงช Add tests for timestamp validation edge cases + +๐ŸŽฏ **What:** The testing gap for timestamp validation is now addressed. +๐Ÿ“Š **Coverage:** The tests cover the happy path, missing Z timezone string, invalid object types, and exceptions when passed malformed ISO strings. +โœจ **Result:** Improved test coverage across error conditions and guarantees deterministic check behaviour. diff --git a/tests/test_validate_program.py b/tests/test_validate_program.py index d408ce3..8d95dfd 100644 --- a/tests/test_validate_program.py +++ b/tests/test_validate_program.py @@ -15,6 +15,7 @@ DEFAULT_REGISTRY, load_json, validate, + _valid_timestamp, ) @@ -471,3 +472,25 @@ def test_priority_view_is_current(self): if __name__ == "__main__": unittest.main() + +class TimestampValidationTests(unittest.TestCase): + def test_valid_timestamp(self): + self.assertTrue(_valid_timestamp("2023-10-10T10:10:10Z")) + self.assertTrue(_valid_timestamp("2023-10-10T10:10:10.123Z")) + self.assertTrue(_valid_timestamp("2023-10-10T10:10:10.123456Z")) + + def test_invalid_type(self): + self.assertFalse(_valid_timestamp(None)) + self.assertFalse(_valid_timestamp(123)) + self.assertFalse(_valid_timestamp({})) + self.assertFalse(_valid_timestamp([])) + + def test_missing_z(self): + self.assertFalse(_valid_timestamp("2023-10-10T10:10:10")) + self.assertFalse(_valid_timestamp("2023-10-10T10:10:10+00:00")) + + def test_malformed_string_with_z(self): + self.assertFalse(_valid_timestamp("invalid-timeZ")) + self.assertFalse(_valid_timestamp("2023-13-10T10:10:10Z")) + self.assertFalse(_valid_timestamp("Z")) + self.assertFalse(_valid_timestamp("not-a-timestampZ"))