
* bugfix/723: pc.data_table not working well with pandas as computed vars Turns out this isnt really a bug. You need to specify an annotation for the computed var to work. This Pr adds a check for annotations on computed vars for data tables * added more validation for column field
90 lines
1.6 KiB
Python
90 lines
1.6 KiB
Python
"""Data display component tests fixtures."""
|
|
from typing import List
|
|
|
|
import pandas as pd
|
|
import pytest
|
|
|
|
import pynecone as pc
|
|
|
|
|
|
@pytest.fixture
|
|
def data_table_state(request):
|
|
"""Get a data table state.
|
|
|
|
Args:
|
|
request: The request.
|
|
|
|
Returns:
|
|
The data table state class.
|
|
"""
|
|
|
|
class DataTableState(pc.State):
|
|
data = request.param["data"]
|
|
columns = ["column1", "column2"]
|
|
|
|
return DataTableState
|
|
|
|
|
|
@pytest.fixture
|
|
def data_table_state2():
|
|
"""Get a data table state.
|
|
|
|
Returns:
|
|
The data table state class.
|
|
"""
|
|
|
|
class DataTableState(pc.State):
|
|
_data = pd.DataFrame()
|
|
|
|
@pc.var # type: ignore
|
|
def data(self):
|
|
return self._data
|
|
|
|
return DataTableState
|
|
|
|
|
|
@pytest.fixture
|
|
def data_table_state3():
|
|
"""Get a data table state.
|
|
|
|
Returns:
|
|
The data table state class.
|
|
"""
|
|
|
|
class DataTableState(pc.State):
|
|
_data: List = []
|
|
_columns: List = ["col1", "col2"]
|
|
|
|
@pc.var # type: ignore
|
|
def data(self) -> List:
|
|
return self._data
|
|
|
|
@pc.var # type: ignore
|
|
def columns(self):
|
|
return self._columns
|
|
|
|
return DataTableState
|
|
|
|
|
|
@pytest.fixture
|
|
def data_table_state4():
|
|
"""Get a data table state.
|
|
|
|
Returns:
|
|
The data table state class.
|
|
"""
|
|
|
|
class DataTableState(pc.State):
|
|
_data: List = []
|
|
_columns: List = ["col1", "col2"]
|
|
|
|
@pc.var # type: ignore
|
|
def data(self):
|
|
return self._data
|
|
|
|
@pc.var # type: ignore
|
|
def columns(self) -> List:
|
|
return self._columns
|
|
|
|
return DataTableState
|