Replies: 1 comment
-
|
Hi @youcefpy, Here is an example for simulating async def receive_file(e: events.UploadEventArguments):
content = await e.file.text()
reader = csv.DictReader(content.splitlines())
ui.table(
columns=[{
'name': h,
'label': h.capitalize(),
'field': h,
} for h in reader.fieldnames or []],
rows=list(reader),
)
ui.upload(on_upload=receive_file)from nicegui import ui
upload = user.find(ui.upload).elements.pop()
await upload.handle_uploads([
ui.upload.SmallFileUpload('data.csv', 'text/csv', b'name,age\nAlice,30\nBob,28')
])
await user.should_see(ui.table)
table = user.find(ui.table).elements.pop()
assert table.columns == [
{'name': 'name', 'label': 'Name', 'field': 'name'},
{'name': 'age', 'label': 'Age', 'field': 'age'},
]
assert table.rows == [
{'name': 'Alice', 'age': '30'},
{'name': 'Bob', 'age': '28'},
] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello i am new on nicegui, i create a simple app where i need to upload the files and store this files on ftp server. I start to make some tests with
nicegui.testing.User(i use this package because i don't need to install the selisium package) i want to know how to simulate a test of uploading fileshow can i simulate a test for uplaoding files ?
Beta Was this translation helpful? Give feedback.
All reactions