How can I assert that a download was triggered with ui.download? #3686
-
QuestionMy UI contains a Right now, it seems like that's not possible. If so, I'm not sure if this is the desired approach, but one way I can see to do this in tests is:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Yes you could create a special outbox for testing purposes. But it can also be archived with the existing tools. Given a page like this @ui.page('/')
def page():
ui.button('Download', on_click=lambda: ui.download(b'Hello', filename='hello.txt')) You could check the download like this: await user.open('/')
user.find('Download').click()
assert user.client
messages = list(user.client.outbox.messages)
assert len(messages) == 1
target_id, message_type, data = messages[0]
assert message_type == 'download'
assert data['src'] == b'Hello'
assert data['filename'] == 'hello.txt' |
Beta Was this translation helpful? Give feedback.
-
I created #3689 to provide such an API. What do you think? |
Beta Was this translation helpful? Give feedback.
I created #3689 to provide such an API. What do you think?