Mercurial > libervia-backend
comparison sat/test/test_plugin_xep_0277.py @ 2562:26edcf3a30eb
core, setup: huge cleaning:
- moved directories from src and frontends/src to sat and sat_frontends, which is the recommanded naming convention
- move twisted directory to root
- removed all hacks from setup.py, and added missing dependencies, it is now clean
- use https URL for website in setup.py
- removed "Environment :: X11 Applications :: GTK", as wix is deprecated and removed
- renamed sat.sh to sat and fixed its installation
- added python_requires to specify Python version needed
- replaced glib2reactor which use deprecated code by gtk3reactor
sat can now be installed directly from virtualenv without using --system-site-packages anymore \o/
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 02 Apr 2018 19:44:50 +0200 |
parents | src/test/test_plugin_xep_0277.py@0046283a285d |
children | 56f94936df1e |
comparison
equal
deleted
inserted
replaced
2561:bd30dc3ffe5a | 2562:26edcf3a30eb |
---|---|
1 #!/usr/bin/env python2 | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # SAT: a jabber client | |
5 # Copyright (C) 2009-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 """ Plugin XEP-0277 tests """ | |
21 | |
22 from sat.test import helpers | |
23 from sat.plugins import plugin_xep_0277 | |
24 from sat.plugins import plugin_xep_0060 | |
25 from sat.plugins import plugin_misc_text_syntaxes | |
26 from sat.tools.xml_tools import ElementParser | |
27 from wokkel.pubsub import NS_PUBSUB | |
28 | |
29 | |
30 class XEP_0277Test(helpers.SatTestCase): | |
31 | |
32 PUBSUB_ENTRY_1 = u""" | |
33 <item id="c745a688-9b02-11e3-a1a3-c0143dd4fe51"> | |
34 <entry xmlns="%s"> | |
35 <title type="text"><span>titre</span></title> | |
36 <id>c745a688-9b02-11e3-a1a3-c0143dd4fe51</id> | |
37 <updated>2014-02-21T16:16:39+02:00</updated> | |
38 <published>2014-02-21T16:16:38+02:00</published> | |
39 <content type="text"><p>contenu</p>texte sans balise<p>autre contenu</p></content> | |
40 <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>contenu</p>texte sans balise<p>autre contenu</p></div></content> | |
41 <author> | |
42 <name>test1@souliane.org</name> | |
43 </author> | |
44 </entry> | |
45 </item> | |
46 """ % plugin_xep_0277.NS_ATOM | |
47 | |
48 PUBSUB_ENTRY_2 = u""" | |
49 <item id="c745a688-9b02-11e3-a1a3-c0143dd4fe51"> | |
50 <entry xmlns='%s'> | |
51 <title type="text"><div>titre</div></title> | |
52 <title type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><div style="background-image: url('xxx');">titre</div></div></title> | |
53 <id>c745a688-9b02-11e3-a1a3-c0143dd4fe51</id> | |
54 <updated>2014-02-21T16:16:39+02:00</updated> | |
55 <published>2014-02-21T16:16:38+02:00</published> | |
56 <content type="text"><div><p>contenu</p>texte dans balise<p>autre contenu</p></div></content> | |
57 <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>contenu</p>texte dans balise<p>autre contenu</p></div></content> | |
58 <author> | |
59 <name>test1@souliane.org</name> | |
60 <nick>test1</nick> | |
61 </author> | |
62 </entry> | |
63 </item> | |
64 """ % plugin_xep_0277.NS_ATOM | |
65 | |
66 def setUp(self): | |
67 self.host = helpers.FakeSAT() | |
68 | |
69 class XEP_0163(object): | |
70 def __init__(self, host): | |
71 pass | |
72 | |
73 def addPEPEvent(self, *args): | |
74 pass | |
75 self.host.plugins["XEP-0060"] = plugin_xep_0060.XEP_0060(self.host) | |
76 self.host.plugins["XEP-0163"] = XEP_0163(self.host) | |
77 reload(plugin_misc_text_syntaxes) # reload the plugin to avoid conflict error | |
78 self.host.plugins["TEXT-SYNTAXES"] = plugin_misc_text_syntaxes.TextSyntaxes(self.host) | |
79 self.plugin = plugin_xep_0277.XEP_0277(self.host) | |
80 | |
81 def test_item2mbdata_1(self): | |
82 expected = {u'id': u'c745a688-9b02-11e3-a1a3-c0143dd4fe51', | |
83 u'atom_id': u'c745a688-9b02-11e3-a1a3-c0143dd4fe51', | |
84 u'title': u'<span>titre</span>', | |
85 u'updated': u'1392992199.0', | |
86 u'published': u'1392992198.0', | |
87 u'content': u'<p>contenu</p>texte sans balise<p>autre contenu</p>', | |
88 u'content_xhtml': u'<div><p>contenu</p>texte sans balise<p>autre contenu</p></div>', | |
89 u'author': u'test1@souliane.org' | |
90 } | |
91 item_elt = ElementParser()(self.PUBSUB_ENTRY_1, namespace=NS_PUBSUB).elements().next() | |
92 d = self.plugin.item2mbdata(item_elt) | |
93 d.addCallback(self.assertEqual, expected) | |
94 return d | |
95 | |
96 def test_item2mbdata_2(self): | |
97 expected = {u'id': u'c745a688-9b02-11e3-a1a3-c0143dd4fe51', | |
98 u'atom_id': u'c745a688-9b02-11e3-a1a3-c0143dd4fe51', | |
99 u'title': u'<div>titre</div>', | |
100 u'title_xhtml': u'<div><div style="">titre</div></div>', | |
101 u'updated': u'1392992199.0', | |
102 u'published': u'1392992198.0', | |
103 u'content': u'<div><p>contenu</p>texte dans balise<p>autre contenu</p></div>', | |
104 u'content_xhtml': u'<div><p>contenu</p>texte dans balise<p>autre contenu</p></div>', | |
105 u'author': u'test1@souliane.org' | |
106 } | |
107 item_elt = ElementParser()(self.PUBSUB_ENTRY_2, namespace=NS_PUBSUB).elements().next() | |
108 d = self.plugin.item2mbdata(item_elt) | |
109 d.addCallback(self.assertEqual, expected) | |
110 return d |