diff --git a/tests/regression/test_datawarehouse_regression.py b/tests/regression/test_datawarehouse_regression.py index 7cfb8bf8..d791fa29 100644 --- a/tests/regression/test_datawarehouse_regression.py +++ b/tests/regression/test_datawarehouse_regression.py @@ -4,6 +4,11 @@ import os import pandas from pathlib import Path +import plotly.express as px +import plotly.io as pio +# The next line is used for the line `pio.templates.default = 'timeseries'`. +# Thus, we don't want the linter to think it is unused. +import xdmod_data.themes # noqa: F401 import pytest from xdmod_data.warehouse import DataWarehouse @@ -226,3 +231,50 @@ def test_get_durations(valid_dw): expected_durations.append(year) actual_durations = list(valid_dw.get_durations()) assert expected_durations == actual_durations + + +def test_first_example_notebook(valid_dw): + pio.templates.default = 'timeseries' + with valid_dw: + data = valid_dw.get_data( + duration=('2016-01-01', '2017-12-31'), + realm='Jobs', + metric='Number of Users: Active', + ) + plot = px.line(data, y='Number of Users: Active') + plot.show() + data['Day Name'] = data.index.strftime('%a') + plot = px.box( + data, + x='Day Name', + y='Number of Users: Active', + category_orders={ + 'Day Name': ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'), + }, + ) + plot.show() + metric_label = 'Number of Users: Active' + with valid_dw: + data = valid_dw.get_data( + duration=('2016-01-01', '2017-12-31'), + realm='Jobs', + metric=metric_label, + dimension='Resource', + ) + plot = px.line(data, labels={'value': metric_label}) + plot.show() + metric_label = 'Number of Users: Active' + with valid_dw: + data = valid_dw.get_data( + duration=('2016-01-01', '2017-12-31'), + realm='Jobs', + metric=metric_label, + dimension='Resource', + dataset_type='aggregate', + ) + plot = px.bar(data, labels={'value': metric_label}) + plot.update_layout( + showlegend=False, + xaxis_automargin=True, + ) + plot.show()