xref: /trunk/test/aoo-test/tests/smoke/test_dump.py (revision 2cb6d6f119bbe2f78742f1c5c8538cb0d4e72ede)
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"""The worker's dump_document op: it reports the document type and the content that the twin tests compare, and leaves no
21document open."""
22import pytest
23
24pytestmark = pytest.mark.smoke
25
26
27@pytest.fixture
28def office(aoo_offices):
29    return aoo_offices.get(None)
30
31
32def stored(office, tmp_path, app, filter, name, text):
33    path = tmp_path / name
34    office.call("new_and_store", {"app": app, "dst": str(path), "filter": filter, "text": text}, timeout=120)
35    return path
36
37
38def test_writer_dump_has_the_text(office, tmp_path):
39    d = office.call("dump_document", {"path": str(stored(office, tmp_path, "writer", "writer8", "d.odt", "Hello Dump"))}, timeout=120)
40    assert d["type"] == "writer" and d["body"]["chars"] == len("Hello Dump") and "body_error" not in d
41
42
43def test_calc_dump_has_the_cell(office, tmp_path):
44    d = office.call("dump_document", {"path": str(stored(office, tmp_path, "calc", "calc8", "d.ods", "Hello Dump"))}, timeout=120)
45    assert d["type"] == "calc" and d["body"]["sheets"][0]["ncells"] == 1
46
47
48def test_different_text_gives_a_different_dump(office, tmp_path):
49    a = office.call("dump_document", {"path": str(stored(office, tmp_path, "writer", "writer8", "a.odt", "Hello Dump"))}, timeout=120)
50    b = office.call("dump_document", {"path": str(stored(office, tmp_path, "writer", "writer8", "b.odt", "Hello Dumps"))}, timeout=120)
51    assert a["body"]["text_hash"] != b["body"]["text_hash"]
52
53
54def test_dump_leaves_nothing_open(office, tmp_path):
55    office.call("dump_document", {"path": str(stored(office, tmp_path, "writer", "writer8", "c.odt", "x"))}, timeout=120)
56    assert office.call("open_documents")["documents"] == []
57