test_download.py 555 B

1234567891011121314151617181920212223
  1. from fastapi import HTTPException
  2. from nicegui import app, ui
  3. from .screen import PORT, Screen
  4. def test_download(screen: Screen):
  5. success = False
  6. @app.get('/static/test.py')
  7. def test():
  8. nonlocal success
  9. success = True
  10. raise HTTPException(404, 'Not found')
  11. ui.button('Download', on_click=lambda: ui.download('static/test.py'))
  12. screen.open('/')
  13. screen.click('Download')
  14. screen.wait(0.5)
  15. assert success
  16. screen.assert_py_logger('WARNING', f'http://localhost:{PORT}/static/test.py not found')