Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notebook regression tests. #62

Draft
wants to merge 6 commits into
base: v1.x.y
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions tests/regression/test_datawarehouse_regression.py
Original file line number Diff line number Diff line change
@@ -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()