Skip to content

Commit

Permalink
fix URL replies & pushing
Browse files Browse the repository at this point in the history
  • Loading branch information
smn committed Apr 8, 2014
1 parent f42da2d commit 6f3c099
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 2 additions & 3 deletions vumi/transports/wechat/message_types.py
Expand Up @@ -115,10 +115,9 @@ def from_vumi_message(cls, match, vumi_message):
from_addr,
vumi_message['timestamp'].strftime('%s'),
[{
'title': 'Title!',
'picurl': 'https://raw.githubusercontent.com/praekelt/vumi-go/develop/go/base/static/img/logo-lrg.png',
'title': '%(before)s' % url_data,
'url': '%(schema)s://%(domain)s' % url_data,
'description': '%(before)s%(after)s' % url_data,
'description': '%(after)s' % url_data,
}])

def to_xml(self):
Expand Down
15 changes: 10 additions & 5 deletions vumi/transports/wechat/tests/test_wechat.py
Expand Up @@ -282,8 +282,8 @@ def test_ack_push_inferred_news_message(self):
yield self.get_transport_with_access_token('foo')
# news is a collection or URLs apparently
msg_d = self.dispatch_push_message(
'This is an awesome link for you! http://www.wechat.com/', {},
to_addr='toaddr')
('This is an awesome link for you! http://www.wechat.com/ '
'Go visit it.'), {}, to_addr='toaddr')

request = yield self.request_queue.get()
self.assertEqual(request.path, '/message/custom/send')
Expand All @@ -296,8 +296,9 @@ def test_ack_push_inferred_news_message(self):
'news': {
'articles': [
{
'description': 'This is an awesome link for you! ',
'title': 'This is an awesome link for you! ',
'url': 'http://www.wechat.com/',
'description': ' Go visit it.'
}
]
}
Expand Down Expand Up @@ -536,11 +537,15 @@ def test_infer_news_message(self):

[msg] = yield self.tx_helper.wait_for_dispatched_inbound(1)
yield self.tx_helper.make_dispatch_reply(
msg, 'This is an awesome link for you! http://www.wechat.com/')
msg, ('This is an awesome link for you! http://www.wechat.com/ '
'Go visit it.'))

resp = yield resp_d
self.assertTrue(
'<Url>http://www.wechat.com/</Url>' in resp.delivered_body)
self.assertTrue(
'<Description>This is an awesome link for you! </Description>'
'<Title>This is an awesome link for you! </Title>'
in resp.delivered_body)
self.assertTrue(
'<Description> Go visit it.</Description>'
in resp.delivered_body)

0 comments on commit 6f3c099

Please sign in to comment.