Skip to content

Commit

Permalink
remove test route after pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Aug 1, 2023
1 parent 3b602ab commit 11133f6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/test_download.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
from typing import Generator

import pytest
from fastapi import HTTPException

from nicegui import app, ui

from .screen import Screen


def test_download(screen: Screen):
@pytest.fixture
def test_route() -> Generator[str, None, None]:
TEST_ROUTE = '/static/test.py'
yield TEST_ROUTE
app.remove_route(TEST_ROUTE)


def test_download(screen: Screen, test_route: str):
success = False

@app.get('/static/test.py')
@app.get(test_route)
def test():
nonlocal success
success = True
raise HTTPException(404, 'Not found')

ui.button('Download', on_click=lambda: ui.download('static/test.py'))
ui.button('Download', on_click=lambda: ui.download(test_route))

screen.open('/')
screen.click('Download')
screen.wait(0.5)
assert success
screen.assert_py_logger('WARNING', f'http://localhost:{Screen.PORT}/static/test.py not found')
screen.assert_py_logger('WARNING', f'http://localhost:{Screen.PORT}{test_route} not found')

0 comments on commit 11133f6

Please sign in to comment.