Mercurial > libervia-backend
comparison sat/test/test_plugin_xep_0297.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 | 378188abe941 |
comparison
equal
deleted
inserted
replaced
2623:49533de4540b | 2624:56f94936df1e |
---|---|
28 from dateutil.tz import tzutc | 28 from dateutil.tz import tzutc |
29 import datetime | 29 import datetime |
30 from wokkel.generic import parseXml | 30 from wokkel.generic import parseXml |
31 | 31 |
32 | 32 |
33 NS_PUBSUB = 'http://jabber.org/protocol/pubsub' | 33 NS_PUBSUB = "http://jabber.org/protocol/pubsub" |
34 | 34 |
35 | 35 |
36 class XEP_0297Test(helpers.SatTestCase): | 36 class XEP_0297Test(helpers.SatTestCase): |
37 | |
38 def setUp(self): | 37 def setUp(self): |
39 self.host = helpers.FakeSAT() | 38 self.host = helpers.FakeSAT() |
40 self.plugin = XEP_0297(self.host) | 39 self.plugin = XEP_0297(self.host) |
41 self.host.plugins['XEP-0203'] = XEP_0203(self.host) | 40 self.host.plugins["XEP-0203"] = XEP_0203(self.host) |
42 | 41 |
43 def test_delay(self): | 42 def test_delay(self): |
44 stanza = parseXml(""" | 43 stanza = parseXml( |
44 """ | |
45 <message from='juliet@capulet.lit/orchard' | 45 <message from='juliet@capulet.lit/orchard' |
46 id='0202197' | 46 id='0202197' |
47 to='romeo@montague.lit' | 47 to='romeo@montague.lit' |
48 type='chat'> | 48 type='chat'> |
49 <body>Yet I should kill thee with much cherishing.</body> | 49 <body>Yet I should kill thee with much cherishing.</body> |
50 <mood xmlns='http://jabber.org/protocol/mood'> | 50 <mood xmlns='http://jabber.org/protocol/mood'> |
51 <amorous/> | 51 <amorous/> |
52 </mood> | 52 </mood> |
53 </message> | 53 </message> |
54 """.encode('utf-8')) | 54 """.encode( |
55 "utf-8" | |
56 ) | |
57 ) | |
55 output = """ | 58 output = """ |
56 <message to='mercutio@verona.lit' type='chat'> | 59 <message to='mercutio@verona.lit' type='chat'> |
57 <body>A most courteous exposition!</body> | 60 <body>A most courteous exposition!</body> |
58 <forwarded xmlns='urn:xmpp:forward:0'> | 61 <forwarded xmlns='urn:xmpp:forward:0'> |
59 <delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:08:25Z'/> | 62 <delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:08:25Z'/> |
69 </message> | 72 </message> |
70 </forwarded> | 73 </forwarded> |
71 </message> | 74 </message> |
72 """ | 75 """ |
73 stamp = datetime.datetime(2010, 7, 10, 23, 8, 25, tzinfo=tzutc()) | 76 stamp = datetime.datetime(2010, 7, 10, 23, 8, 25, tzinfo=tzutc()) |
74 d = self.plugin.forward(stanza, JID('mercutio@verona.lit'), stamp, | 77 d = self.plugin.forward( |
75 body='A most courteous exposition!', | 78 stanza, |
76 profile_key=C.PROFILE[0]) | 79 JID("mercutio@verona.lit"), |
77 d.addCallback(lambda dummy: self.assertEqualXML(self.host.getSentMessageXml(0), output, True)) | 80 stamp, |
81 body="A most courteous exposition!", | |
82 profile_key=C.PROFILE[0], | |
83 ) | |
84 d.addCallback( | |
85 lambda dummy: self.assertEqualXML( | |
86 self.host.getSentMessageXml(0), output, True | |
87 ) | |
88 ) | |
78 return d | 89 return d |