Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding environ argument to enable testing of forms #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Adding environ argument to enable testing of forms #9

wants to merge 4 commits into from

Conversation

oceanites
Copy link

I tried to test my application using boddle and stumpled upon two problems:

  • As @signalw mentioned in throw error if 'environ' in extra arg. remove extra_orig. #7: forms is not testable
  • I'm using beaker for session handling and tried to add the data using the extra args:
    • boddle(beaker.session='session') obviously doesn't work (It tries to access attribute session from a not existing beaker object), as well as boddle('beaker.session'='session')
    • When providing it as a dictionary boddle(**{'beaker.session': 'session'}), the value is stored in bottle.request.ext.beaker.session and therefore, only accessible with getattr(bottle.request, 'beaker.session')

To solve this issue i propose adding an extra argument environ for the context manager. This solves both issues, forms can be preset with boddle(environ={'bottle.request.forms': formdata}). Beaker session data using boddle(environ={'beaker.session': sessiondata}).

@Marrin
Copy link

Marrin commented Sep 26, 2019

This seems also be useful/needed to test routes with Basic Auth to set the REMOTE_USER environment variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants