class SectionTwo(Section): empty_string = StringOption() empty_integer = IntegerOption() empty_float = FloatOption() empty_boolean = BooleanOption() empty_list = StringListOption() missing_key = StringOption()
class SectionOne(Section): string = StringOption() multiline_string = StringOption() list = StringListOption() integer = IntegerOption() float = FloatOption() boolean = BooleanOption()
class ServerSection(Section): """Server settings, including session.""" ip = StringOption(doc="IP address to listen on", default='0.0.0.0') port = IntegerOption(doc="port to listen on", default=8000) debug = BooleanOption(doc=("debug status, determines verbosity and " "automatic template reloading"), default=False) session_secret = StringOption(doc="44 character ASCII encoded secret") session_max_age = IntegerOption( doc="maximum age of session in seconds", default=315360000)
def test_validate(): # valid trees ini_validate(None, OrderedDict()) ini_validate( None, OrderedDict([('section_a', Section()), ('section_b', Section())])) class SectionA(Section): element_a = StringOption() class SectionB(Section): element_b = IntegerOption() element_c = BooleanOption() element_d = FloatOption() ini_validate( None, OrderedDict([('section_a', SectionA()), ('section_b', SectionB())])) # invalid trees with pytest.raises(InvalidConfigTree): ini_validate(None, "nonsense") with pytest.raises(InvalidConfigTree): ini_validate(None, {}) with pytest.raises(InvalidConfigTree): ini_validate(None, [EmptySection()]) with pytest.raises(InvalidConfigTree): ini_validate(None, OrderedDict(something_else=5)) with pytest.raises(InvalidConfigTree): ini_validate(None, OrderedDict(not_a_section=StringOption())) class NestedSection(Section): another_section = EmptySection() with pytest.raises(InvalidConfigTree): ini_validate(None, OrderedDict(nested_section=NestedSection())) unsupported_option = StringOption() unsupported_option.type_ = "nonsense" with pytest.raises(InvalidConfigTree): ini_validate(None, OrderedDict(unsupported_option=unsupported_option))
class SectionA(Section): element_a = StringOption()
class MySection(Section): string = StringOption(default="value", required=False) item_two = StringOption(doc="option two", default="2")
class MySection(Section): string = StringOption(default="a\nb\nc", required=False)
class MySection(Section): string = StringOption(default="value", required=False)
class MySection(Section): string = StringOption(doc="test", required=False)
class MySection(Section): string = StringOption(doc="test", default="value", required=True)
class NotificationSection(Section): """Notification message data. Fill out this section for default values.""" title = StringOption(doc='notification title', required=True) message = StringOption(doc='notification message', required=True)
class AuthenticationSection(Section): """Settings for aiohttp-login.""" theme = StringOption(doc="theme to use for authentication pages", default='auth') common_theme = StringOption( doc="theme directory for unthemed authentication pages", default='common') # password_len = IntegerPairOption(default=(6, 10)) login_redirect = StringOption(doc="URL to redirect to after login", default='/') logout_redirect = StringOption(doc="URL to redirect to after logout", default='auth_login') registration_confirmation_required = BooleanOption( doc="require e-mail confirmation after registration?", default=True) # admin_emails = StringListOption(default=[]) csrf_secret = StringOption(doc="cross site redirect forgery secret") back_url_qs_key = StringOption( doc="URL key to indicate page to return to", default='back_to') session_user_key = StringOption(doc="key for user field in session", default='user') request_user_key = StringOption(doc="key for user field in request", default='user') session_flash_key = StringOption( doc="key for flash messages field in session", default='flash') request_flash_incoming_key = StringOption( doc="key for incoming flash messages in request", default='flash_incoming') request_flash_outgoing_key = StringOption( doc="key for outgoing flash messages in request", default='flash_outgoing') flash_queue_limit = IntegerOption( doc="maximum number of flash messages in queue", default=10) vkontakte_id = StringOption( doc="id for the vkontakte authentication service", required=False) vkontakte_secret = StringOption( doc="secret for the vkontakte authentication service", required=False) google_id = StringOption( doc="id for the google authentication service", required=False) google_secret = StringOption( doc="secret for the google authentication service", required=False) facebook_id = StringOption( doc="id for the facebook authentication service", required=False) facebook_secret = StringOption( doc="secret for the facebook authentication service", required=False) smtp_sender = StringOption( doc="content of the from header field for e-mail", required=False) smtp_host = StringOption(doc="address of your SMTP server") smtp_port = IntegerOption(doc="port of your SMTP server", default=587) smtp_tls = BooleanOption(doc="use transport layer security", default=True) smtp_username = StringOption(doc="SMTP username", required=False) smtp_password = StringOption(doc="SMTP password", required=False) registration_confirmation_lifetime = IntegerOption( doc= "number of days before a registration confirmation link expires", default=5) reset_password_confirmation_lifetime = IntegerOption( doc="number of days before a password reset link expires", default=5) change_email_confirmation_lifetime = IntegerOption( doc= "number of days before an e-mail change confirmation link expires", default=5) msg_logged_in = StringOption( doc="message to display on successful login", default='You are logged in') msg_logged_out = StringOption(doc="message to display after logout", default='You are logged out') msg_activated = StringOption( doc="message to display on successful account activation", default='Your account is activated') msg_unknown_email = StringOption( doc="message to display if e-mail is not registered", default='This email is not registered') msg_wrong_password = StringOption( doc="message to display if password is incorrect", default='Wrong password') msg_user_banned = StringOption( doc="message to display of banned user tries to login", default='This user is banned') msg_activation_required = StringOption( doc="message to display if e-mail has not been verified", default=('You have to activate your account via' ' email, before you can login')) msg_email_exists = StringOption( doc="message to display a e-mail is already registered", default='This email is already registered') msg_often_reset_password = StringOption( doc=("message to display if password restoration has " "already been requested"), default=('You can\'t request restoring your password so often. ' 'Please, use the link we sent you recently')) msg_cant_send_mail = StringOption( doc="message to display if there is a problem sending e-mail", default='Can\'t send email, try a little later') msg_passwords_not_match = StringOption( doc="message to display if passwords don't match", default='Passwords must match') msg_password_changed = StringOption( doc="message to display after successful password change", default='Your password is changed') msg_change_email_requested = StringOption( doc=("message to display after e-mail change has been " "requested, but not verified"), default=('Please, click on the verification link' ' we sent to your new email address')) msg_email_changed = StringOption( doc="message to display after e-mail change has been verified", default='Your email is changed') msg_auth_failed = StringOption( doc="message to display if authorisation failed", default='Authorization failed')
class ServerSection(Section): listen = StringOption(doc='IP to listen on', default='0.0.0.0') port = IntegerOption(doc='port to listen on', default=5757) pid_file = StringOption(doc='path to PID file', default='/tmp/netnotify.pid')
class SectionWithContent(Section): string = StringOption(default="value")
class AddressSection(Section): """shipping address""" street = StringOption(doc="street including house number", required=True) city = StringOption(required=True)
class GeneralSection(Section): """General information.""" name = StringOption(doc="your name", default="unknown person") age = IntegerOption(doc="your age", required=True)
class ServerSection(Section): address = StringOption(doc='server address', default='127.0.0.1') port = IntegerOption(doc='port server is listening on', default=5757)
class LogSection(Section): log_file = StringOption(doc='file to write logs to', default='/var/log/netnotify.log') verbosity = StringOption( doc='one of critical, error, warning, info, debug or notset', default='warning')
class MySection(Section): string = StringOption(required=True)
class MySection(Section): string = StringOption(required=False)
class MySection(Section): name = StringOption(default="test")
class GeneralSection(Section): """General section.""" string = StringOption(default="default")