1################################################################ 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. You may obtain a copy of the License at 10# 11# http://www.apache.org/licenses/LICENSE-2.0 12# 13# Unless required by applicable law or agreed to in writing, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20################################################################ 21 22"""crosscheck.check(): odfvalidator on the negative controls, compared with jing.""" 23import pytest 24 25from aootest import tools 26from aootest.checkers import crosscheck 27 28pytestmark = [pytest.mark.selftest, pytest.mark.needs_java] 29 30 31@pytest.fixture(scope="module") 32def cross(val, odf_controls, schema_dir, tmp_path_factory): 33 jar, java = tools.odfvalidator(), tools.java() 34 if jar is None or java is None: 35 pytest.skip("needs java and the odfvalidator jar (set AOO_ODFVALIDATOR or run: python -m aootest.fetch)") 36 return crosscheck.check(odf_controls, val, tmp_path_factory.mktemp("cross"), jar, schema_dir, java) 37 38 39ROWS = [ 40 ("odfvalidator flags bad.odt in both modes", lambda c, e: all("bad.odt/content.xml" in m["odfvalidator_error_streams"] for m in (c, e))), 41 ("odfvalidator flags extforeign.odt as written but not as an extended document", 42 lambda c, e: "extforeign.odt/content.xml" in c["odfvalidator_error_streams"] and "extforeign.odt/content.xml" not in e["odfvalidator_error_streams"]), 43 ("odfvalidator finds the duplicate xml:id that jing -i cannot", lambda c, e: "dupid.odt/content.xml" in c["odfvalidator_error_streams"]), 44 ("good.odt clean in odfvalidator", lambda c, e: not any("good.odt/" in k for m in (c, e) for k in m["odfvalidator_error_streams"])), 45 ("no stream where only jing reports errors", lambda c, e: not c["only_jing"] and not e["only_jing"]), 46] 47 48 49@pytest.mark.parametrize("row", [pytest.param(r[1], id=r[0]) for r in ROWS]) 50def test_crosscheck_controls(row, cross): 51 assert row(cross["conformance"], cross["extended"]) 52