Mercurial > libervia-backend
annotate tests/e2e/libervia-cli/test_libervia-cli.py @ 3728:b15644cae50d
component AP gateway: JID/node ⟺ AP outbox conversion:
- convert a combination of JID and optional pubsub node to AP actor handle (see
`getJIDAndNode` for details) and vice versa
- the gateway now provides a Pubsub service
- retrieve pubsub node and convert it to AP collection, AP pagination is converted to RSM
- do the opposite: convert AP collection to pubsub and handle RSM request. Due to
ActivityStream collection pagination limitations, some RSM request produce inefficient
requests, but caching should be used most of the time in the future and avoid the
problem.
- set specific name to HTTP Server
- new `local_only` setting (`True` by default) to indicate if the gateway can request or
not XMPP Pubsub nodes from other servers
- disco info now specifies important features such as Pubsub RSM, and nodes metadata
ticket 363
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 25 Jan 2022 17:54:06 +0100 |
parents | eeb8be32d644 |
children | 7e51cfc36d4e |
rev | line source |
---|---|
3415 | 1 #!/usr/bin/env python3 |
2 | |
3480
7550ae9cfbac
Renamed the project from "Salut à Toi" to "Libervia":
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
3 # Libervia: an XMPP client |
3479 | 4 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
3415 | 5 |
6 # This program is free software: you can redistribute it and/or modify | |
7 # it under the terms of the GNU Affero General Public License as published by | |
8 # the Free Software Foundation, either version 3 of the License, or | |
9 # (at your option) any later version. | |
10 | |
11 # This program is distributed in the hope that it will be useful, | |
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 # GNU Affero General Public License for more details. | |
15 | |
16 # You should have received a copy of the GNU Affero General Public License | |
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 import os | |
20 import shutil | |
21 import pytest | |
22 import sh | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
23 from sh import li |
3415 | 24 from sat.tools.common import uri |
25 | |
26 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
27 if os.getenv("LIBERVIA_TEST_ENV_E2E") is None: |
3415 | 28 pytest.skip( |
29 "skipping end-to-end tests, we are not in a test environment", | |
30 allow_module_level=True | |
31 ) | |
32 | |
33 | |
34 pytestmark = pytest.mark.usefixtures("test_profiles") | |
35 | |
36 | |
37 class TestInstall: | |
38 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
39 def test_li_can_run(self): |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
40 li("--version") |
3415 | 41 |
42 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
43 class TestLiberviaCliAccount: |
3415 | 44 |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
45 def test_create_and_delete(self, li_json): |
3415 | 46 """Create an account in-band, connect it, then delete it and its profile""" |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
47 li.account.create( |
3415 | 48 "test_create@server1.test", |
49 "test", | |
50 profile="test_create", | |
51 host="server1.test" | |
52 ) | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
53 profiles = li_json.profile.list() |
3415 | 54 assert "test_create" in profiles |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
55 li.profile.connect(connect=True, profile="test_create") |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
56 li.account.delete(profile="test_create", force=True) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
57 li.profile.delete("test_create", force=True) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
58 profiles = li_json.profile.list() |
3415 | 59 assert "test_create" not in profiles |
60 | |
61 | |
62 @pytest.mark.usefixtures("pubsub_nodes") | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
63 class TestLiberviaCliPubsub: |
3415 | 64 |
65 def test_node_create_info_delete(self): | |
66 node_name = "tmp_node" | |
67 with pytest.raises(sh.ErrorReturnCode_16): | |
68 # the node should not exist | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
69 li.pubsub.node.info(node=node_name) |
3415 | 70 try: |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
71 li.pubsub.node.create(node=node_name) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
72 # if node exist as expected, following command won't raise an exception |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
73 metadata = li.pubsub.node.info(node=node_name) |
3415 | 74 assert len(metadata.strip()) |
75 finally: | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
76 li.pubsub.node.delete(node=node_name, force=True) |
3415 | 77 |
78 with pytest.raises(sh.ErrorReturnCode_16): | |
79 # the node should not exist anymore | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
80 li.pubsub.node.info(node=node_name) |
3415 | 81 |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
82 def test_set_get_delete_purge(self, li_elt): |
3415 | 83 content = "test item" |
84 payload = f"<test>{content}</test>" | |
85 | |
86 # we create 3 items and check them | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
87 item1_id = li.pubsub.set(node="test", quiet=True, _in=payload) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
88 item2_id = li.pubsub.set(node="test", quiet=True, _in=payload) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
89 item3_id = li.pubsub.set(node="test", quiet=True, _in=payload) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
90 parsed_elt = li_elt.pubsub.get(node="test", item=item1_id) |
3415 | 91 payload = parsed_elt.firstChildElement() |
92 assert payload.name == 'test' | |
93 assert str(payload) == content | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
94 parsed_elt = li_elt.pubsub.get(node="test", item=item2_id) |
3415 | 95 payload = parsed_elt.firstChildElement() |
96 assert payload.name == 'test' | |
97 assert str(payload) == content | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
98 parsed_elt = li_elt.pubsub.get(node="test", item=item3_id) |
3415 | 99 payload = parsed_elt.firstChildElement() |
100 assert payload.name == 'test' | |
101 assert str(payload) == content | |
102 | |
103 # deleting first item should work | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
104 li.pubsub.delete(node="test", item=item1_id, force=True) |
3415 | 105 with pytest.raises(sh.ErrorReturnCode_16): |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
106 li.pubsub.get(node="test", item=item1_id) |
3415 | 107 |
108 # there must be a least item2 and item3 in the node | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
109 node_items = li_elt.pubsub.get(node="test") |
3415 | 110 assert len(list(node_items.elements())) >= 2 |
111 | |
112 # after purge, node must be empty | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
113 li.pubsub.node.purge(node="test", force=True) |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
114 node_items = li_elt.pubsub.get(node="test") |
3415 | 115 assert len(list(node_items.elements())) == 0 |
116 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
117 def test_edit(self, editor, li_elt): |
3415 | 118 content = "original item" |
119 payload = f"<test>{content}</test>" | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
120 item_id = li.pubsub.set(node="test", quiet=True, _in=payload) |
3415 | 121 editor.set_filter('content.replace("original", "edited")') |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
122 li.pubsub.edit(node="test", item=item_id, _env=editor.env) |
3415 | 123 assert "original item" in editor.original_content |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
124 parsed_elt = li_elt.pubsub.get(node="test", item=item_id) |
3415 | 125 edited_payload = parsed_elt.firstChildElement() |
126 expected_edited_content = content.replace("original", "edited") | |
127 assert edited_payload.name == 'test' | |
128 assert str(edited_payload) == expected_edited_content | |
129 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
130 def test_affiliations(self, li_json): |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
131 affiliations = li_json.pubsub.affiliations() |
3415 | 132 assert affiliations["test"] == "owner" |
133 | |
134 def test_uri(self): | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
135 built_uri = li.pubsub.uri( |
3415 | 136 service="pubsub.example.net", node="some_node" |
137 ).strip() | |
138 assert built_uri == "xmpp:pubsub.example.net?;node=some_node" | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
139 built_uri = li.pubsub.uri( |
3415 | 140 service="pubsub.example.net", node="some_node", item="some_item" |
141 ).strip() | |
142 assert built_uri == "xmpp:pubsub.example.net?;node=some_node;item=some_item" | |
143 | |
3674
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
144 def test_cache_search(self, li_json): |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
145 """A Full-Text Search query can be done""" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
146 sk_txt = "this is a blog post about Slovakia" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
147 fr_txt = "this is a blog post about France" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
148 nc_txt = "this is a blog post about New Caledonia" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
149 au_txt = "this is a blog post about Australia" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
150 li.blog.set( |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
151 "-t", "travel", "-t", "europe", |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
152 _in=sk_txt, |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
153 syntax="markdown" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
154 ) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
155 li.blog.set( |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
156 "-t", "travel", "-t", "europe", |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
157 _in=fr_txt, |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
158 syntax="markdown" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
159 ) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
160 li.blog.set( |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
161 "-t", "travel", "-t", "south pacific", |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
162 _in=nc_txt, |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
163 syntax="markdown" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
164 ) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
165 li.blog.set( |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
166 "-t", "travel", "-t", "south pacific", |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
167 _in="this is a blog post about Australia", |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
168 title=au_txt, |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
169 syntax="markdown" |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
170 ) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
171 # we get the blog to be activate the cache for it |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
172 li.blog.get(max_items=1) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
173 # FTS |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
174 found = li_json.pubsub.cache.search(type="blog", fts='Slovakia OR "New Caledonia"') |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
175 assert len(found) == 2 |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
176 assert all(i["content"] in (sk_txt, nc_txt) for i in found) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
177 # search by field |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
178 found = li_json.pubsub.cache.search("-F", "tags", "overlap", "travel", type="blog") |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
179 assert len(found) == 4 |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
180 found = li_json.pubsub.cache.search("-F", "tags", "overlap", "europe", type="blog") |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
181 assert len(found) == 2 |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
182 assert all(i["content"] in (sk_txt, fr_txt) for i in found) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
183 found = li_json.pubsub.cache.search("-F", "tags", "ioverlap", "SOUTH PACIFIC", type="blog") |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
184 assert all(i["content"] in (nc_txt, au_txt) for i in found) |
eeb8be32d644
tests (e2e/CLI): tests for Pubsub Cache Search
Goffi <goffi@goffi.org>
parents:
3658
diff
changeset
|
185 |
3415 | 186 |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
187 class TestLiberviaCliBlog: |
3415 | 188 MICROBLOG_NS = "urn:xmpp:microblog:0" |
189 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
190 def test_set_get(self, li_json): |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
191 li.blog.set(_in="markdown **bold** [link](https://example.net)") |
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
192 item_data = li_json.blog.get(max=1) |
3415 | 193 item = item_data[0][0] |
194 metadata = item_data[1] | |
195 assert metadata['service'] == "account1@server1.test" | |
196 assert metadata['node'] == self.MICROBLOG_NS | |
197 assert metadata['rsm'].keys() <= {"first", "last", "index", "count"} | |
198 item_id = item['id'] | |
199 expected_uri = uri.buildXMPPUri( | |
200 'pubsub', subtype="microblog", path="account1@server1.test", | |
201 node=self.MICROBLOG_NS, item=item_id | |
202 ) | |
203 assert item['uri'] == expected_uri | |
204 assert item['content_xhtml'] == ( | |
205 '<div><p>markdown <strong>bold</strong> ' | |
206 '<a href="https://example.net">link</a></p></div>' | |
207 ) | |
208 assert isinstance(item['published'], int) | |
209 assert isinstance(item['updated'], int) | |
210 assert isinstance(item['comments'], list) | |
211 assert isinstance(item['tags'], list) | |
212 assert item['author'] == 'account1' | |
213 assert item['author_jid'] == 'account1@server1.test' | |
214 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
215 def test_edit(self, editor, li_json): |
3415 | 216 payload_md = "content in **markdown**" |
217 editor.set_filter(repr(payload_md)) | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
218 li.blog.edit(_env=editor.env) |
3415 | 219 assert len(editor.original_content) == 0 |
220 assert editor.new_content == payload_md | |
3658
9e491b2bab88
test (e2e/cli): use `max_items` instead of `max` when retrieving blog items:
Goffi <goffi@goffi.org>
parents:
3498
diff
changeset
|
221 items_data = li_json.blog.get(max_items=1) |
3415 | 222 last_item = items_data[0][0] |
223 last_item_id = last_item['id'] | |
224 assert last_item['content'] == "content in markdown" | |
225 assert last_item['content_xhtml'] == ( | |
226 "<div><p>content in <strong>markdown</strong></p></div>" | |
227 ) | |
228 editor.set_filter('f"{content} extended"') | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
229 li.blog.edit("--last-item", _env=editor.env) |
3415 | 230 assert editor.original_content == payload_md |
231 assert editor.new_content == f"{payload_md} extended" | |
3658
9e491b2bab88
test (e2e/cli): use `max_items` instead of `max` when retrieving blog items:
Goffi <goffi@goffi.org>
parents:
3498
diff
changeset
|
232 items_data = li_json.blog.get(max_items=1) |
3415 | 233 last_item = items_data[0][0] |
234 # we check that the id hasn't been modified | |
235 assert last_item['id'] == last_item_id | |
236 assert last_item['content'] == "content in markdown extended" | |
237 assert last_item['content_xhtml'] == ( | |
238 "<div><p>content in <strong>markdown</strong> extended</p></div>" | |
239 ) | |
240 | |
241 | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
242 class TestLiberviaCliFile: |
3415 | 243 |
244 def test_upload_get(self, fake_file): | |
245 source_file = fake_file.size(10240) | |
246 source_file_hash = fake_file.get_source_hash(source_file) | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
247 upload_url = li.file.upload(source_file).strip() |
3415 | 248 |
249 dest_file = fake_file.new_dest_file() | |
250 try: | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
251 li.file.get(upload_url, dest_file=dest_file) |
3415 | 252 dest_file_hash = fake_file.get_dest_hash(dest_file) |
253 finally: | |
254 dest_file.unlink() | |
255 | |
256 assert source_file_hash == dest_file_hash | |
257 | |
258 def test_send_receive(self, fake_file): | |
259 source_file = fake_file.size(10240) | |
260 source_file_hash = fake_file.get_source_hash(source_file) | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
261 send_cmd = li.file.send(source_file, "account1@server2.test", _bg=True) |
3415 | 262 dest_path = fake_file.dest_files / "test_send_receive" |
263 dest_path.mkdir() | |
264 try: | |
3498
d78b5eae912a
tests: update following names change
Goffi <goffi@goffi.org>
parents:
3480
diff
changeset
|
265 li.file.receive( |
3415 | 266 "account1@server1.test", profile="account1_s2", path=dest_path) |
267 dest_file = dest_path / source_file.name | |
268 dest_file_hash = fake_file.get_dest_hash(dest_file) | |
269 finally: | |
270 shutil.rmtree(dest_path) | |
271 send_cmd.wait() | |
272 | |
273 assert source_file_hash == dest_file_hash |