Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def send_xml(self, xml):
message = parse_user_msg(xml)
return self.send(message)
def test_subscribe_event():
message = parse_user_msg(
"""
123456789
"""
)
assert message.target == "toUser"
assert message.source == "FromUser"
assert message.time == 123456789
assert message.type == "subscribe_event"
message = parse_user_msg(
def test_image():
@werobot.image
def image(message):
return '图片喵'
message = parse_user_msg(
"""
1348831860
1234567890123456
"""
)
reply = werobot.get_reply(message)
assert isinstance(reply, TextReply)
assert reply._args['content'] == u'图片喵'
def test_wechat_reply():
message = parse_user_msg(
"""
1348831860
1234567890123456
"""
)
s = to_binary("喵fdsjaklfsk")
reply = WeChatReply(message=message, s=s)
assert reply._args['source'] == 'toUser'
assert reply._args['target'] == 'fromUser'
def test_card_pay_order_event():
message = parse_user_msg(
"""
1453295737
1453295737
0
def test_none_message():
assert not parse_user_msg("")
def test_user_consume_card_event():
message = parse_user_msg(
"""
1472549042
"""
123456789
"""
)
assert message.target == "toUser"
assert message.source == "FromUser"
assert message.time == 123456789
assert message.type == "subscribe_event"
message = parse_user_msg(
"""
123456789
"""
)
assert message.target == "toUser"
assert message.source == "FromUser"
assert message.time == 123456789
assert message.type == "subscribe_event"
assert message.key == "qrscene_123123"
def test_unknown_event():
message = parse_user_msg(
"""
123456789
"""
)
assert message.target == "toUser"
assert message.source == "FromUser"
assert message.time == 123456789
assert message.type == "unknown_event"
from werobot.utils import to_text
class NoNameMessage(object):
test_int = IntEntry("TestInt")
test_string_to_int = IntEntry("TestStringToInt")
test_float_to_int = IntEntry("TestFloatToInt")
test_int_none = IntEntry("MIAOMIAOMIAO")
test_float = FloatEntry("TestFloat")
test_string_to_float = FloatEntry("TestStringToFloat")
test_float_none = FloatEntry("WANGWANG")
test_string = StringEntry("TestString")
test_int_to_string = StringEntry("TestIntToString")
test_float_to_string = StringEntry("TestFloatToString")
test_chinese = StringEntry("TestChinese")
test_string_none = StringEntry("HAHAHA")
def __init__(self):
message = {
"TestInt": 123,
"TestFloat": 0.00001,
"TestString": "hello",
"TestStringToInt": "123",
"TestFloatToInt": 123.000,
"TestStringToFloat": "0.00001",
"TestIntToString": 123,
"TestFloatToString": 0.00001,
"TestChinese": "喵",
}
self.__dict__.update(message)