def test_bot_for_select_registration_conference( mock_response_requests_post, mock_obj_vk_api, mock_long_poll, mock_vk_api_get, mock_users_get_messages_send, ): bot = VKBot() for bot.event in bot.vk_bot_pollster.listen( cmd=CMD_SIGN_UP_FOR_CONFERENCE): bot.on_event_from_dict() assert bot.event.object['message']['text'] == CMD_SIGN_UP_FOR_CONFERENCE assert bot.status_bot_sing_up_conf assert bot.message_from_bot == CMD_SIGN_UP_FOR_CONFERENCE_ANSWER assert bot.message_send_exec_code == 600
def test_bot_for_list_commands( cmd, mock_response_requests_get, mock_response_requests_post, mock_obj_vk_api, mock_long_poll, mock_vk_api_get, mock_users_get_messages_send, ): bot = VKBot() for bot.event in bot.vk_bot_pollster.listen(cmd=cmd): bot.on_event_from_dict() assert bot.event.object['message']['text'] == CMD_LST_revers.pop() assert bot.message_from_bot == CMD_LST_ANSWER_revers.pop() assert bot.message_send_exec_code == 600
def test_bot_for_no_command( mock_response_requests_get, mock_response_requests_post, mock_obj_vk_api, mock_long_poll, mock_vk_api_get, mock_users_get_messages_send, ): bot = VKBot() for bot.event in bot.vk_bot_pollster.listen(cmd=CMD_NO_COMMAND): bot.on_event_from_dict() assert bot.event.object['message']['text'] == CMD_NO_COMMAND assert bot.user_info[0]['first_name'] == 'Urik' assert bot.user_info[0]['last_name'] == 'Kireev' assert bot.message_from_bot == CMD_NO_COMMAND_ANSWER assert bot.message_send_exec_code == 600 assert bot.log_send_status_code == 2000
def test_bot_for_intents_registration_conference( cmd, mock_response_requests_get, mock_response_requests_post, mock_obj_vk_api, mock_long_poll, mock_vk_api_get, mock_users_get_messages_send, ): bot = VKBot() bot.user_id = 77209884 for bot.event in bot.vk_bot_pollster.listen(cmd=cmd): bot.status_bot_sing_up_conf = True bot.on_event_from_dict() assert bot.event.object['message'][ 'text'] == REG_CONF_INTENTS_LST_INPUT_revers.pop() assert bot.message_from_bot == REG_CONF_INTENTS_LST_ANSWER_revers.pop() assert bot.message_send_exec_code == 600
def test_bot_for_scenario_registration_conference( cmd, scenario_name, step_name, context, number_call, mock_response_requests_get_for_registration, mock_response_requests_post, mock_response_requests_put, mock_response_requests_delete, mock_obj_vk_api, mock_long_poll, mock_vk_api_get, mock_users_get_messages_send, mock_send_ticket_image_fixture): bot = VKBot() for bot.event in bot.vk_bot_pollster.listen(cmd=cmd): bot.status_bot_sing_up_conf = True if scenario_name: bot.user_states[77209884] = UserState(scenario_name=scenario_name, step_name=step_name, context=context) bot.on_event_from_dict() assert bot.event.object['message'][ 'text'] == REG_CONF_SCENARIO_LST_INPUT_revers.pop()[0] assert bot.message_from_bot == REG_CONF_SCENARIO_LST_ANSWER_revers.pop() assert bot.message_send_exec_code == 600
) cur.execute( "CREATE TABLE IF NOT EXISTS reposts (link TEXT, peer_id TEXT, time TEXT, screen_name TEXT, " "first_name TEXT, message TEXT)") cur.execute( "CREATE INDEX IF NOT EXISTS idx_peer_id_link ON reposts (peer_id, link)") db.commit() def create_app(): app = Flask(__name__) # existing code omitted import db db.init_app(app) return app app = create_app() bot = VKBot(os.environ["VK_TOKEN"], os.environ["VK_CODE"]) bot.add_handler(handlers.play_pidor_handler) bot.add_handler(handlers.pidor_stats_handler) bot.add_handler(handlers.shame_repost_handler) @app.route("/ab4cacaee19bfd6d463096709cdadcab", methods=["POST"]) def main(): data = request.get_json(force=True, silent=True) return bot.handle(data)