Mercurial > libervia-web
annotate browser/libervia_test.py @ 1199:b300eaec53b6
server: don't raise error anymore if themes_dir is invalid or legacy blog can't be created:
legacy blog will be entirely removed with 0.8 release, and themes_dir is only used by it.
This patch limit troubles with this old code by not raising an error anymore if option is
wrong or if the legacy blog can't be created.
fix 317
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 09 Jul 2019 20:20:46 +0200 |
parents | 2af117bfe6cc |
children |
rev | line source |
---|---|
602
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
3 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
1144 | 5 # Copyright (C) 2011-2019 Jérôme Poisson <goffi@goffi.org> |
602
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
6 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
10 # (at your option) any later version. |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
11 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
15 # GNU Affero General Public License for more details. |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
16 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
19 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
20 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
21 # Just visit <root_url>/test. If you don't get any AssertError pop-up, |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
22 # everything is fine. #TODO: nicely display the results in HTML output. |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
23 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
24 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
25 ### logging configuration ### |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
26 from sat_browser import logging |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
27 logging.configure() |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
28 from sat.core.log import getLogger |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
29 log = getLogger(__name__) |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
30 ### |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
31 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
32 from sat_frontends.tools import jid |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
33 from sat_browser import contact_list |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
34 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
35 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
36 def test_JID(): |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
37 """Check that the JID class reproduces the Twisted behavior""" |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
38 j1 = jid.JID("t1@test.org") |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
39 j1b = jid.JID("t1@test.org") |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
40 t1 = "t1@test.org" |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
41 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
42 assert j1 == j1b |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
43 assert j1 != t1 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
44 assert t1 != j1 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
45 assert hash(j1) == hash(j1b) |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
46 assert hash(j1) != hash(t1) |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
47 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
48 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
49 def test_JIDIterable(): |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
50 """Check that our iterables reproduce the Twisted behavior""" |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
51 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
52 j1 = jid.JID("t1@test.org") |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
53 j1b = jid.JID("t1@test.org") |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
54 j2 = jid.JID("t2@test.org") |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
55 t1 = "t1@test.org" |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
56 t2 = "t2@test.org" |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
57 jid_set = set([j1, t2]) |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
58 jid_list = contact_list.JIDList([j1, t2]) |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
59 jid_dict = {j1: "dummy 1", t2: "dummy 2"} |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
60 for iterable in (jid_set, jid_list, jid_dict): |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
61 log.info("Testing %s" % type(iterable)) |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
62 assert j1 in iterable |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
63 assert j1b in iterable |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
64 assert j2 not in iterable |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
65 assert t1 not in iterable |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
66 assert t2 in iterable |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
67 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
68 # Check that the extra JIDList class is still needed |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
69 log.info("Testing Pyjamas native list") |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
70 jid_native_list = ([j1, t2]) |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
71 assert j1 in jid_native_list |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
72 assert j1b not in jid_native_list # this is NOT Twisted's behavior |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
73 assert j2 in jid_native_list # this is NOT Twisted's behavior |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
74 assert t1 in jid_native_list # this is NOT Twisted's behavior |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
75 assert t2 in jid_native_list |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
76 |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
77 test_JID() |
be3fd3874c3a
add very basic test system accessible from <root_url>/test, to be improved:
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
78 test_JIDIterable() |