import os
import pytest
import pynecone as pc
@pytest.fixture
def upload_component():
"""A test upload component function.
Returns:
A test upload component function.
"""
def upload_component():
return pc.upload(
pc.button("select file"),
pc.text("Drag and drop files here or click to select files"),
border="1px dotted black",
)
return upload_component()
@pytest.fixture
def upload_component_with_props():
"""A test upload component with props function.
Returns:
A test upload component with props function.
"""
def upload_component_with_props():
return pc.upload(
pc.button("select file"),
pc.text("Drag and drop files here or click to select files"),
border="1px dotted black",
no_drag=True,
max_files=2,
)
return upload_component_with_props()
def test_upload_component_render(upload_component):
"""Test that the render function is set correctly.
Args:
upload_component: component fixture
"""
assert (
str(upload_component) == f" File(e)}>{({getRootProps, getInputProps}) => ({os.linesep}'
f"{os.linesep}"
"{`Drag and drop files here or click to select "
"files`})}"
)
def test_upload_component_with_props_render(upload_component_with_props):
"""Test that the render function is set correctly.
Args:
upload_component_with_props: component fixture
"""
assert (
str(upload_component_with_props) == f" File(e)}>{({getRootProps, getInputProps}) => ({os.linesep}'
f"{os.linesep}"
"{`Drag and drop files here or click to select "
"files`})}"
)