Mercurial > libervia-backend
comparison sat/test/test_plugin_xep_0277.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | 003b8b4b56a7 |
comparison
equal
deleted
inserted
replaced
2623:49533de4540b | 2624:56f94936df1e |
---|---|
27 from wokkel.pubsub import NS_PUBSUB | 27 from wokkel.pubsub import NS_PUBSUB |
28 | 28 |
29 | 29 |
30 class XEP_0277Test(helpers.SatTestCase): | 30 class XEP_0277Test(helpers.SatTestCase): |
31 | 31 |
32 PUBSUB_ENTRY_1 = u""" | 32 PUBSUB_ENTRY_1 = ( |
33 u""" | |
33 <item id="c745a688-9b02-11e3-a1a3-c0143dd4fe51"> | 34 <item id="c745a688-9b02-11e3-a1a3-c0143dd4fe51"> |
34 <entry xmlns="%s"> | 35 <entry xmlns="%s"> |
35 <title type="text"><span>titre</span></title> | 36 <title type="text"><span>titre</span></title> |
36 <id>c745a688-9b02-11e3-a1a3-c0143dd4fe51</id> | 37 <id>c745a688-9b02-11e3-a1a3-c0143dd4fe51</id> |
37 <updated>2014-02-21T16:16:39+02:00</updated> | 38 <updated>2014-02-21T16:16:39+02:00</updated> |
41 <author> | 42 <author> |
42 <name>test1@souliane.org</name> | 43 <name>test1@souliane.org</name> |
43 </author> | 44 </author> |
44 </entry> | 45 </entry> |
45 </item> | 46 </item> |
46 """ % plugin_xep_0277.NS_ATOM | 47 """ |
48 % plugin_xep_0277.NS_ATOM | |
49 ) | |
47 | 50 |
48 PUBSUB_ENTRY_2 = u""" | 51 PUBSUB_ENTRY_2 = ( |
52 u""" | |
49 <item id="c745a688-9b02-11e3-a1a3-c0143dd4fe51"> | 53 <item id="c745a688-9b02-11e3-a1a3-c0143dd4fe51"> |
50 <entry xmlns='%s'> | 54 <entry xmlns='%s'> |
51 <title type="text"><div>titre</div></title> | 55 <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> | 56 <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> | 57 <id>c745a688-9b02-11e3-a1a3-c0143dd4fe51</id> |
59 <name>test1@souliane.org</name> | 63 <name>test1@souliane.org</name> |
60 <nick>test1</nick> | 64 <nick>test1</nick> |
61 </author> | 65 </author> |
62 </entry> | 66 </entry> |
63 </item> | 67 </item> |
64 """ % plugin_xep_0277.NS_ATOM | 68 """ |
69 % plugin_xep_0277.NS_ATOM | |
70 ) | |
65 | 71 |
66 def setUp(self): | 72 def setUp(self): |
67 self.host = helpers.FakeSAT() | 73 self.host = helpers.FakeSAT() |
68 | 74 |
69 class XEP_0163(object): | 75 class XEP_0163(object): |
70 def __init__(self, host): | 76 def __init__(self, host): |
71 pass | 77 pass |
72 | 78 |
73 def addPEPEvent(self, *args): | 79 def addPEPEvent(self, *args): |
74 pass | 80 pass |
81 | |
75 self.host.plugins["XEP-0060"] = plugin_xep_0060.XEP_0060(self.host) | 82 self.host.plugins["XEP-0060"] = plugin_xep_0060.XEP_0060(self.host) |
76 self.host.plugins["XEP-0163"] = XEP_0163(self.host) | 83 self.host.plugins["XEP-0163"] = XEP_0163(self.host) |
77 reload(plugin_misc_text_syntaxes) # reload the plugin to avoid conflict error | 84 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) | 85 self.host.plugins["TEXT-SYNTAXES"] = plugin_misc_text_syntaxes.TextSyntaxes( |
86 self.host | |
87 ) | |
79 self.plugin = plugin_xep_0277.XEP_0277(self.host) | 88 self.plugin = plugin_xep_0277.XEP_0277(self.host) |
80 | 89 |
81 def test_item2mbdata_1(self): | 90 def test_item2mbdata_1(self): |
82 expected = {u'id': u'c745a688-9b02-11e3-a1a3-c0143dd4fe51', | 91 expected = { |
83 u'atom_id': u'c745a688-9b02-11e3-a1a3-c0143dd4fe51', | 92 u"id": u"c745a688-9b02-11e3-a1a3-c0143dd4fe51", |
84 u'title': u'<span>titre</span>', | 93 u"atom_id": u"c745a688-9b02-11e3-a1a3-c0143dd4fe51", |
85 u'updated': u'1392992199.0', | 94 u"title": u"<span>titre</span>", |
86 u'published': u'1392992198.0', | 95 u"updated": u"1392992199.0", |
87 u'content': u'<p>contenu</p>texte sans balise<p>autre contenu</p>', | 96 u"published": u"1392992198.0", |
88 u'content_xhtml': u'<div><p>contenu</p>texte sans balise<p>autre contenu</p></div>', | 97 u"content": u"<p>contenu</p>texte sans balise<p>autre contenu</p>", |
89 u'author': u'test1@souliane.org' | 98 u"content_xhtml": u"<div><p>contenu</p>texte sans balise<p>autre contenu</p></div>", |
90 } | 99 u"author": u"test1@souliane.org", |
91 item_elt = ElementParser()(self.PUBSUB_ENTRY_1, namespace=NS_PUBSUB).elements().next() | 100 } |
101 item_elt = ( | |
102 ElementParser()(self.PUBSUB_ENTRY_1, namespace=NS_PUBSUB).elements().next() | |
103 ) | |
92 d = self.plugin.item2mbdata(item_elt) | 104 d = self.plugin.item2mbdata(item_elt) |
93 d.addCallback(self.assertEqual, expected) | 105 d.addCallback(self.assertEqual, expected) |
94 return d | 106 return d |
95 | 107 |
96 def test_item2mbdata_2(self): | 108 def test_item2mbdata_2(self): |
97 expected = {u'id': u'c745a688-9b02-11e3-a1a3-c0143dd4fe51', | 109 expected = { |
98 u'atom_id': u'c745a688-9b02-11e3-a1a3-c0143dd4fe51', | 110 u"id": u"c745a688-9b02-11e3-a1a3-c0143dd4fe51", |
99 u'title': u'<div>titre</div>', | 111 u"atom_id": u"c745a688-9b02-11e3-a1a3-c0143dd4fe51", |
100 u'title_xhtml': u'<div><div style="">titre</div></div>', | 112 u"title": u"<div>titre</div>", |
101 u'updated': u'1392992199.0', | 113 u"title_xhtml": u'<div><div style="">titre</div></div>', |
102 u'published': u'1392992198.0', | 114 u"updated": u"1392992199.0", |
103 u'content': u'<div><p>contenu</p>texte dans balise<p>autre contenu</p></div>', | 115 u"published": u"1392992198.0", |
104 u'content_xhtml': u'<div><p>contenu</p>texte dans balise<p>autre contenu</p></div>', | 116 u"content": u"<div><p>contenu</p>texte dans balise<p>autre contenu</p></div>", |
105 u'author': u'test1@souliane.org' | 117 u"content_xhtml": u"<div><p>contenu</p>texte dans balise<p>autre contenu</p></div>", |
106 } | 118 u"author": u"test1@souliane.org", |
107 item_elt = ElementParser()(self.PUBSUB_ENTRY_2, namespace=NS_PUBSUB).elements().next() | 119 } |
120 item_elt = ( | |
121 ElementParser()(self.PUBSUB_ENTRY_2, namespace=NS_PUBSUB).elements().next() | |
122 ) | |
108 d = self.plugin.item2mbdata(item_elt) | 123 d = self.plugin.item2mbdata(item_elt) |
109 d.addCallback(self.assertEqual, expected) | 124 d.addCallback(self.assertEqual, expected) |
110 return d | 125 return d |