comparison browser/libervia_test.py @ 1124:28e3eb3bb217

files reorganisation and installation rework: - files have been reorganised to follow other SàT projects and usual Python organisation (no more "/src" directory) - VERSION file is now used, as for other SàT projects - replace the overcomplicated setup.py be a more sane one. Pyjamas part is not compiled anymore by setup.py, it must be done separatly - removed check for data_dir if it's empty - installation tested working in virtual env - libervia launching script is now in bin/libervia
author Goffi <goffi@goffi.org>
date Sat, 25 Aug 2018 17:59:48 +0200
parents src/browser/libervia_test.py@f2170536ba23
children 2af117bfe6cc
comparison
equal deleted inserted replaced
1123:63a4b8fe9782 1124:28e3eb3bb217
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Libervia: a Salut à Toi frontend
5 # Copyright (C) 2011-2018 Jérôme Poisson <goffi@goffi.org>
6
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Affero General Public License for more details.
16
17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20
21 # Just visit <root_url>/test. If you don't get any AssertError pop-up,
22 # everything is fine. #TODO: nicely display the results in HTML output.
23
24
25 ### logging configuration ###
26 from sat_browser import logging
27 logging.configure()
28 from sat.core.log import getLogger
29 log = getLogger(__name__)
30 ###
31
32 from sat_frontends.tools import jid
33 from sat_browser import contact_list
34
35
36 def test_JID():
37 """Check that the JID class reproduces the Twisted behavior"""
38 j1 = jid.JID("t1@test.org")
39 j1b = jid.JID("t1@test.org")
40 t1 = "t1@test.org"
41
42 assert j1 == j1b
43 assert j1 != t1
44 assert t1 != j1
45 assert hash(j1) == hash(j1b)
46 assert hash(j1) != hash(t1)
47
48
49 def test_JIDIterable():
50 """Check that our iterables reproduce the Twisted behavior"""
51
52 j1 = jid.JID("t1@test.org")
53 j1b = jid.JID("t1@test.org")
54 j2 = jid.JID("t2@test.org")
55 t1 = "t1@test.org"
56 t2 = "t2@test.org"
57 jid_set = set([j1, t2])
58 jid_list = contact_list.JIDList([j1, t2])
59 jid_dict = {j1: "dummy 1", t2: "dummy 2"}
60 for iterable in (jid_set, jid_list, jid_dict):
61 log.info("Testing %s" % type(iterable))
62 assert j1 in iterable
63 assert j1b in iterable
64 assert j2 not in iterable
65 assert t1 not in iterable
66 assert t2 in iterable
67
68 # Check that the extra JIDList class is still needed
69 log.info("Testing Pyjamas native list")
70 jid_native_list = ([j1, t2])
71 assert j1 in jid_native_list
72 assert j1b not in jid_native_list # this is NOT Twisted's behavior
73 assert j2 in jid_native_list # this is NOT Twisted's behavior
74 assert t1 in jid_native_list # this is NOT Twisted's behavior
75 assert t2 in jid_native_list
76
77 test_JID()
78 test_JIDIterable()