Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_config_attribute():
robot = WeRoBot(SESSION_STORAGE=False)
assert not robot.token
token = generate_token()
robot.config["TOKEN"] = token
assert robot.token == token
token = generate_token()
robot.token = token
assert robot.config["TOKEN"] == token
def hello_robot():
from werobot import WeRoBot
robot = WeRoBot(token='', SESSION_STORAGE=False)
@robot.text
def hello():
return 'hello'
@robot.error_page
def make_error_page(url):
return '喵'
return robot
def test_register_not_callable_object():
robot = WeRoBot(SESSION_STORAGE=False)
with pytest.raises(ValueError):
robot.add_handler("s")
def robot(self):
from werobot import WeRoBot
robot = WeRoBot(token=self.token, SESSION_STORAGE=False)
@robot.text
def hello():
return 'hello'
@robot.error_page
def make_error_page(url):
return '喵'
return robot
def test_robot_client(self):
robot = WeRoBot()
assert robot.client.config == robot.config
def test_session():
robot = werobot.WeRoBot(
token=werobot.utils.generate_token(), enable_session=True
)
@robot.text
def first(message, session):
if 'last' in session:
return
session['last'] = message.content
return message.content
@robot.text
def second(_, session):
return session['last']
tester = werobot.testing.WeTest(robot)
xml_1 = """
# -*- coding: utf-8 -*-
import werobot
robot = werobot.WeRoBot(token='tokenhere')
@robot.text
def hello_world(message):
return 'Hello World!'
@robot.filter("帮助")
def show_help(message):
return """
帮助
XXXXX
"""
robot.run()