mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 06:52:59 +00:00
Handle file upload in spawner form
Allow files to be uploaded in the spawner form.
This commit is contained in:
@@ -119,3 +119,31 @@ def test_spawn_form(app, io_loop):
|
||||
'notspecified': 5,
|
||||
}
|
||||
|
||||
def test_spawn_form_with_file(app, io_loop):
|
||||
with mock.patch.dict(app.users.settings, {'spawner_class': FormSpawner}):
|
||||
base_url = ujoin(app.proxy.public_server.host, app.hub.server.base_url)
|
||||
cookies = app.login_user('jones')
|
||||
orm_u = orm.User.find(app.db, 'jones')
|
||||
u = app.users[orm_u]
|
||||
io_loop.run_sync(u.stop)
|
||||
|
||||
r = requests.post(ujoin(base_url, 'spawn'),
|
||||
cookies=cookies,
|
||||
data={
|
||||
'bounds': ['-1', '1'],
|
||||
'energy': '511keV',
|
||||
},
|
||||
files={'hello': ('hello.txt', b'hello world\n')}
|
||||
)
|
||||
r.raise_for_status()
|
||||
print(u.spawner)
|
||||
print(u.spawner.user_options)
|
||||
assert u.spawner.user_options == {
|
||||
'energy': '511keV',
|
||||
'bounds': [-1, 1],
|
||||
'notspecified': 5,
|
||||
'hello': {'filename': 'hello.txt',
|
||||
'body': b'hello world\n',
|
||||
'content_type': 'application/unknown'},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user