-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[QA] Vizro-ai base dashboard tests (#607)
Co-authored-by: Lingyi Zhang <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maximilian Schulz <[email protected]> Co-authored-by: nadijagraca <[email protected]>
- Loading branch information
1 parent
3187e0b
commit 221bd71
Showing
6 changed files
with
119 additions
and
4 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
vizro-ai/changelog.d/20240805_140630_alexey_snigir_vizro_ai_dashboard_tests.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!-- | ||
A new scriv changelog fragment. | ||
Uncomment the section that is right (remove the HTML comment wrapper). | ||
--> | ||
|
||
<!-- | ||
### Highlights ✨ | ||
- A bullet item for the Highlights ✨ category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Removed | ||
- A bullet item for the Removed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Added | ||
- A bullet item for the Added category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Changed | ||
- A bullet item for the Changed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Deprecated | ||
- A bullet item for the Deprecated category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Fixed | ||
- A bullet item for the Fixed category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> | ||
<!-- | ||
### Security | ||
- A bullet item for the Security category with a link to the relevant PR at the end of your entry, e.g. Enable feature XXX ([#1](https://github.com/mckinsey/vizro/pull/1)) | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pytest | ||
from vizro import Vizro | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def reset_managers(): | ||
# this ensures that the managers are reset before and after each test | ||
# the reset BEFORE all tests is important because at pytest test collection, fixtures are evaluated and hence | ||
# the model_manager may be populated with models from other tests | ||
Vizro._reset() | ||
yield | ||
Vizro._reset() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
"""Tests for dashboard using VizroAI.""" | ||
|
||
import os | ||
|
||
import chromedriver_autoinstaller | ||
import pytest | ||
import vizro.plotly.express as px | ||
from vizro import Vizro | ||
from vizro_ai import VizroAI | ||
|
||
vizro_ai = VizroAI() | ||
|
||
df1 = px.data.gapminder() | ||
df2 = px.data.stocks() | ||
|
||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def setup_test_environment(): | ||
# We only need to install chromedriver outside CI. | ||
if not os.getenv("CI"): | ||
chromedriver_autoinstaller.install() | ||
|
||
|
||
@pytest.mark.filterwarnings("ignore::langchain_core._api.beta_decorator.LangChainBetaWarning") | ||
@pytest.mark.filterwarnings("ignore::UserWarning") | ||
@pytest.mark.filterwarnings("ignore:HTTPResponse.getheader()") | ||
def test_simple_dashboard(dash_duo): | ||
input_text = """ | ||
I need a page with 1 table. | ||
The table shows the tech companies stock data. | ||
I need a second page showing 2 cards and one chart. | ||
The first card says 'The Gapminder dataset provides historical data on countries' development indicators.' | ||
The chart is an scatter plot showing life expectancy vs. GDP per capita by country. Life expectancy on the y axis, | ||
GDP per capita on the x axis, and colored by continent. | ||
The second card says 'Data spans from 1952 to 2007 across various countries.' | ||
The layout uses a grid of 3 columns and 2 rows. | ||
Row 1: The first row has three columns: | ||
The first column is occupied by the first card. | ||
The second and third columns are spanned by the chart. | ||
Row 2: The second row mirrors the layout of the first row with respect to chart, but the first column is occupied | ||
by the second card. | ||
Add a filter to filter the scatter plot by continent. | ||
Add a second filter to filter the chart by year. | ||
""" | ||
|
||
dashboard = vizro_ai.dashboard([df1, df2], input_text) | ||
app = Vizro().build(dashboard).dash | ||
dash_duo.start_server(app) | ||
assert dash_duo.get_logs() == [] |