annotate browser/libervia_test.py @ 1128:6414fd795df4

server, pages: multi-sites refactoring: Libervia is now handling external sites (i.e. other sites than Libervia official site). The external site are declared in sites_path_public_dict (in [DEFAULT] section) which is read by template engine, then they are linked to virtual host with vhosts_dict (linking host name to site name) in [libervia] section. Sites are only instanced once, so adding an alias is just a matter of mapping the alias host name in vhosts_dict with the same site name. menu_json and url_redirections_dict can now accept keys named after site name, which will be linked to the data for the site. Data for default site can still be keyed at first level. Libervia official pages are added to external site (if pages are not overriden), allowing to call pages of the framework and to have facilities like login handling. Deprecated url_redirections_profile option has been removed.
author Goffi <goffi@goffi.org>
date Fri, 14 Sep 2018 21:41:28 +0200
parents 28e3eb3bb217
children 2af117bfe6cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1054
f2170536ba23 date update
Goffi <goffi@goffi.org>
parents: 964
diff changeset
5 # Copyright (C) 2011-2018 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()