Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
maxschulz-COL committed Oct 23, 2023
1 parent 5548fa2 commit 3329484
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion vizro-core/src/vizro/models/_components/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Table(VizroBaseModel):
# Convenience wrapper/syntactic sugar.
def __call__(self, **kwargs):
kwargs.setdefault("data_frame", data_manager._get_component_data(self.id)) # type: ignore[arg-type]
return self.table(**kwargs)
return self.figure(**kwargs)

# Convenience wrapper/syntactic sugar.
def __getitem__(self, arg_name: str):
Expand Down
21 changes: 10 additions & 11 deletions vizro-core/tests/unit/vizro/models/_components/test_table.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
"""Unit tests for vizro.models.Table."""
import json

import pandas as pd
import plotly
import pytest
from dash import dcc
from dash import dash_table, html
from pydantic import ValidationError

import vizro.models as vm
import vizro.plotly.express as px
from vizro.managers import data_manager
from vizro.models._action._action import Action
from vizro.tables import dash_data_table
import plotly
from dash import dash_table, html

import pandas as pd


@pytest.fixture
def standard_dash_table():
return dash_data_table(data_frame=px.data.gapminder())


@pytest.fixture
def dash_table_with_arguments():
return dash_data_table(data_frame=px.data.gapminder(), style_header={"border": "1px solid green"})


@pytest.fixture
def dash_table_with_str_dataframe():
return dash_data_table(data_frame="gapminder")


@pytest.fixture
def expected_table():
return html.Div(
dash_table.DataTable(pd.DataFrame().to_dict("records"), []), id="text_table"
)
return html.Div(dash_table.DataTable(pd.DataFrame().to_dict("records"), []), id="text_table")


class TestDunderMethodsTable:
def test_create_graph_mandatory_only(self, standard_dash_table):
Expand All @@ -59,14 +59,14 @@ def test_mandatory_figure_missing(self):
with pytest.raises(ValidationError, match="field required"):
vm.Table()

def test_failed_graph_with_no_captured_callable(self, standard_go_chart):
def test_failed_table_with_no_captured_callable(self, standard_go_chart):
with pytest.raises(ValidationError, match="must provide a valid CapturedCallable object"):
vm.Table(
figure=standard_go_chart,
)

@pytest.mark.xfail(reason="This test is failing as we are not yet detecting different types of captured callables")
def test_failed_graph_with_no_captured_callable(self, standard_px_chart):
def test_failed_table_with_wrong_captured_callable(self, standard_px_chart):
with pytest.raises(ValidationError, match="must provide a valid table function vm.Table"):
vm.Table(
figure=standard_px_chart,
Expand Down Expand Up @@ -118,7 +118,6 @@ def test_process_figure_data_frame_df(self, standard_dash_table, gapminder):
table_with_str_df.figure["data_frame"]



class TestBuildTable:
def test_graph_build(self, standard_dash_table, expected_table):
table = vm.Table(
Expand Down

0 comments on commit 3329484

Please sign in to comment.