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"""Documents the worker builds (aootest_worker.ops.generate) saved in each ODF save mode and loaded again: the values the 21checks in data/checks/ read from the saved copy must be the ones recorded for them. Differences between save modes that are 22known are rows in data/expect/reload.tsv.""" 23import pytest 24 25from aootest import documents 26from aootest.odfversion import SAVE_MODES 27 28pytestmark = pytest.mark.slow 29 30BUILT = [s for s in documents.generated() if s.checks] 31RELOAD = [(m, s.id, f, c["name"]) for m in SAVE_MODES for s in BUILT for f in s.checks for c in documents.load_checks(f)] 32 33 34@pytest.mark.parametrize("mode,source_id,checks,name", RELOAD, ids=["%s|%s|%s" % (m, i, n) for m, i, f, n in RELOAD]) 35def test_reload_check(odf_runs, need_mode, mode, source_id, checks, name): 36 need_mode(mode) 37 run = odf_runs(mode) 38 saved = run.saved()[source_id] 39 assert saved["out"], "not saved: %s" % saved["detail"] 40 got = run.reload_checks()[source_id] 41 assert "__error__" not in got, got.get("__error__") 42 expected = {c["name"]: c["expect"] for c in documents.load_checks(checks)}[name] 43 assert got[name] == expected 44