1*2cb6d6f1SJim Jagielski################################################################ 2*2cb6d6f1SJim Jagielski# 3*2cb6d6f1SJim Jagielski# Licensed to the Apache Software Foundation (ASF) under one 4*2cb6d6f1SJim Jagielski# or more contributor license agreements. See the NOTICE file 5*2cb6d6f1SJim Jagielski# distributed with this work for additional information 6*2cb6d6f1SJim Jagielski# regarding copyright ownership. The ASF licenses this file 7*2cb6d6f1SJim Jagielski# to you under the Apache License, Version 2.0 (the 8*2cb6d6f1SJim Jagielski# "License"); you may not use this file except in compliance 9*2cb6d6f1SJim Jagielski# with the License. You may obtain a copy of the License at 10*2cb6d6f1SJim Jagielski# 11*2cb6d6f1SJim Jagielski# http://www.apache.org/licenses/LICENSE-2.0 12*2cb6d6f1SJim Jagielski# 13*2cb6d6f1SJim Jagielski# Unless required by applicable law or agreed to in writing, 14*2cb6d6f1SJim Jagielski# software distributed under the License is distributed on an 15*2cb6d6f1SJim Jagielski# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2cb6d6f1SJim Jagielski# KIND, either express or implied. See the License for the 17*2cb6d6f1SJim Jagielski# specific language governing permissions and limitations 18*2cb6d6f1SJim Jagielski# under the License. 19*2cb6d6f1SJim Jagielski# 20*2cb6d6f1SJim Jagielski################################################################ 21*2cb6d6f1SJim Jagielski 22*2cb6d6f1SJim Jagielski"""Against a real install, when AOO_OFFICE names one. Nothing here starts the office: it reads files and imports uno in a child Python.""" 23*2cb6d6f1SJim Jagielskiimport os 24*2cb6d6f1SJim Jagielski 25*2cb6d6f1SJim Jagielskiimport pytest 26*2cb6d6f1SJim Jagielski 27*2cb6d6f1SJim Jagielskifrom aootest import install 28*2cb6d6f1SJim Jagielski 29*2cb6d6f1SJim Jagielskipytestmark = [pytest.mark.smoke, pytest.mark.skipif(not os.environ.get("AOO_OFFICE"), reason="set AOO_OFFICE to an installed AOO 5 to run this")] 30*2cb6d6f1SJim Jagielski 31*2cb6d6f1SJim Jagielski 32*2cb6d6f1SJim Jagielski@pytest.fixture(scope="module") 33*2cb6d6f1SJim Jagielskidef layout(): 34*2cb6d6f1SJim Jagielski return install.discover() 35*2cb6d6f1SJim Jagielski 36*2cb6d6f1SJim Jagielski 37*2cb6d6f1SJim Jagielskidef test_layout_matches_the_version_file(layout): 38*2cb6d6f1SJim Jagielski text = layout.version_file.read_text() 39*2cb6d6f1SJim Jagielski assert "OOOBaseVersion=%s" % layout.version.base in text 40*2cb6d6f1SJim Jagielski assert layout.soffice.is_file() and layout.fundamental.is_file() and layout.pyuno_module is not None 41*2cb6d6f1SJim Jagielski assert layout.version.tuple >= install.MIN_VERSION 42*2cb6d6f1SJim Jagielski 43*2cb6d6f1SJim Jagielski 44*2cb6d6f1SJim Jagielskidef test_a_python_can_import_uno(layout, tmp_path): 45*2cb6d6f1SJim Jagielski try: 46*2cb6d6f1SJim Jagielski py = install.find_uno_python(layout, cache_file=tmp_path / "uno.json") 47*2cb6d6f1SJim Jagielski except install.NoUnoPython as e: 48*2cb6d6f1SJim Jagielski pytest.skip("no UNO Python for this install: %s; tried %s" % (e, e.tried)) 49*2cb6d6f1SJim Jagielski assert os.path.exists(py.path) and tuple(int(x) for x in py.version.split(".")[:2]) >= install.MIN_WORKER_PYTHON 50