from typing import List import re import decimal import logging import operator from urllib.parse import unquote, urlsplit from html.parser import HTMLParser import otree.constants from otree.models_concrete import ParticipantToPlayerLookup from django import test from django.urls import resolve from django.conf import settings from otree.currency import Currency from otree.models import Participant, Session from otree import common from otree.common import ( get_dotted_name, get_bots_module, get_admin_secret_code, get_models_module, ) ADMIN_SECRET_CODE = get_admin_secret_code() logger = logging.getLogger('otree.bots') INTERNAL_FORM_FIELDS = { 'csrfmiddlewaretoken', 'must_fail', 'timeout_happened', 'admin_secret_code', 'error_fields', } DISABLE_CHECK_HTML_INSTRUCTIONS = ''' Checking the HTML may not find all form fields and buttons (e.g. those added with JavaScript), so you can disable this check by yielding a Submission with check_html=False, e.g.: yield Submission(views.PageName, {{...}}, check_html=False) ''' HTML_MISSING_BUTTON_WARNING = ( ( ''' Bot is trying to submit page {page_name}, but no button was found in the HTML of the page. (searched for with type='submit' or