diff --git a/schema/suite_v2_0.xsd b/schema/suite_v2_0.xsd index 51afeece..0753ee97 100644 --- a/schema/suite_v2_0.xsd +++ b/schema/suite_v2_0.xsd @@ -17,6 +17,12 @@ + + + + + + @@ -32,8 +38,8 @@ - - + + @@ -41,8 +47,8 @@ - - + + @@ -51,8 +57,8 @@ - - + + @@ -94,7 +100,6 @@ - @@ -122,7 +127,7 @@ - + @@ -142,8 +147,8 @@ - - + + diff --git a/test/unit_tests/sample_suite_files/suite_invalid_group_fortran_id.xml b/test/unit_tests/sample_suite_files/suite_invalid_group_fortran_id.xml new file mode 100644 index 00000000..0fbb40dc --- /dev/null +++ b/test/unit_tests/sample_suite_files/suite_invalid_group_fortran_id.xml @@ -0,0 +1,8 @@ + + + + + scheme1 + scheme2 + + diff --git a/test/unit_tests/sample_suite_files/suite_invalid_scheme_fortran_id.xml b/test/unit_tests/sample_suite_files/suite_invalid_scheme_fortran_id.xml new file mode 100644 index 00000000..e236cbd0 --- /dev/null +++ b/test/unit_tests/sample_suite_files/suite_invalid_scheme_fortran_id.xml @@ -0,0 +1,8 @@ + + + + + scheme-1 + scheme2 + + diff --git a/test/unit_tests/sample_suite_files/suite_invalid_suite_fortran_id.xml b/test/unit_tests/sample_suite_files/suite_invalid_suite_fortran_id.xml new file mode 100644 index 00000000..ae8a28a4 --- /dev/null +++ b/test/unit_tests/sample_suite_files/suite_invalid_suite_fortran_id.xml @@ -0,0 +1,8 @@ + + + + + scheme1 + scheme2 + + diff --git a/test/unit_tests/test_sdf.py b/test/unit_tests/test_sdf.py index 5dd73d95..fbb2c1db 100644 --- a/test/unit_tests/test_sdf.py +++ b/test/unit_tests/test_sdf.py @@ -371,7 +371,7 @@ def test_bad_v2_suite_duplicate_group1(self): _ = validate_xml_file(compare, 'suite', schema_version, logger) # end with emsg = "Schemas validity error : Element 'group', attribute 'name': " + \ - "'group1' is not a valid value of the atomic type 'xs:ID'" + "'group1' is not a valid value of the atomic type 'fortran_id_type_unique'" fmsg = str(context.exception) self.assertTrue(emsg in fmsg, msg=fmsg) if not emsg in fmsg: @@ -534,3 +534,36 @@ def test_missing_schema_version(self): # Check exception for expected error messages self.assertTrue("version attribute required" in str(context.exception), msg=f"Bad exception for missing suite version") + + def test_invalid_fortran_id(self): + """Test that verification system recognizes a bad Fortran ID entry""" + num_tests = 3 + header = "Test trapping of invalid Fortran ID" + tests = [ + "suite_invalid_scheme_fortran_id", + "suite_invalid_group_fortran_id", + "suite_invalid_suite_fortran_id", + ] + exc_strings = [ + "The value 'scheme-1' is not accepted by the pattern '[A-Za-z][A-Za-z0-9_]{0,63}", + "The value 'group-1' is not accepted by the pattern '[A-Za-z][A-Za-z0-9_]{0,63}", + "The value 'ver-test-suite' is not accepted by the pattern '[A-Za-z][A-Za-z0-9_]{0,63}", + ] + for test_num in range(num_tests): + # Setup + testname = tests[test_num] + source = os.path.join(_SAMPLE_FILES_DIR, f"{testname}.xml") + logger = self.get_logger() + _, xml_root = read_xml_file(source, logger) + schema_version = find_schema_version(xml_root) + self.assertEqual(schema_version[0], 2) + self.assertEqual(schema_version[1], 0) + # Exercise + with self.assertRaises(Exception) as context: + res = validate_xml_file(source, 'suite', schema_version, logger) + # end with + # Check exception for expected error messages + exp_str = str(context.exception) + self.assertTrue(exc_strings[test_num] in exp_str, + msg=f"Bad exception in test {test_num + 1}, '{exp_str}'") + # end for