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