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"""pkgcheck.check() must report exactly the (level, rule) pairs each control package was built to trigger.""" 23import pytest 24 25from aootest import controls 26 27pytestmark = pytest.mark.selftest 28 29EXPECTED = controls.make_pkg_controls(None) 30 31 32def found(result, pkg): 33 msgs = (e[3] for e in result["errors"] if e[0].startswith(pkg + "/")) 34 return sorted({tuple(m.split("]")[0].split(": [")) for m in msgs}) 35 36 37@pytest.mark.parametrize("pkg", sorted(EXPECTED), ids=lambda p: "%s reports exactly %s" % (p, ", ".join(r for _, r in EXPECTED[p]) or "nothing")) 38def test_pkgcheck_control(pkg, pkg_result): 39 assert found(pkg_result, pkg) == [tuple(x) for x in EXPECTED[pkg]] 40 41 42def test_pkgcheck_table_is_not_empty(): 43 assert len(EXPECTED) > 20 44