""" Unit tests for NATO STANAG schema validation engine. """ import unittest from open_stanag.schema_validator import ( get_validator, validate_stanag_4774, validate_stanag_4778, assert_valid_stanag_4774, assert_valid_stanag_4778, SchemaValidationError, ) class TestSchemaValidator(unittest.TestCase): def test_schema_compilation(self): v = get_validator() self.assertIsNotNone(v.schema_4774) self.assertIsNotNone(v.schema_4778) def test_valid_label_xml(self): xml = """ NATO SECRET 2026-11-17T08:00:00Z """ valid, errors = validate_stanag_4774(xml) self.assertTrue(valid, f"Validation errors: {errors}") self.assertEqual(len(errors), 0) def test_invalid_label_missing_creation_datetime(self): xml = """ NATO SECRET """ valid, errors = validate_stanag_4774(xml) self.assertFalse(valid) self.assertGreater(len(errors), 0) with self.assertRaises(SchemaValidationError): assert_valid_stanag_4774(xml) def test_valid_binding_xml(self): xml = """ NATO UNCLASSIFIED 2026-11-17T08:00:00Z """ valid, errors = validate_stanag_4778(xml) self.assertTrue(valid, f"Validation errors: {errors}") def test_invalid_binding_empty(self): xml = """""" valid, errors = validate_stanag_4778(xml) self.assertFalse(valid) if __name__ == "__main__": unittest.main()