-
Notifications
You must be signed in to change notification settings - Fork 799
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: respect data transformer for chart.serve() and chart.save()
- Loading branch information
Showing
5 changed files
with
95 additions
and
19 deletions.
There are no files selected for viewing
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,33 @@ | ||
import os | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
from .. import data as alt | ||
|
||
|
||
@pytest.fixture | ||
def sample_data(): | ||
return pd.DataFrame({'x': range(10), 'y': range(10)}) | ||
|
||
|
||
def test_disable_max_rows(sample_data): | ||
with alt.data_transformers.enable('default', max_rows=5): | ||
# Ensure max rows error is raised. | ||
with pytest.raises(alt.MaxRowsError): | ||
alt.data_transformers.get()(sample_data) | ||
|
||
# Ensure that max rows error is properly disabled. | ||
with alt.data_transformers.disable_max_rows(): | ||
alt.data_transformers.get()(sample_data) | ||
|
||
try: | ||
with alt.data_transformers.enable('json'): | ||
# Ensure that there is no TypeError for non-max_rows transformers. | ||
with alt.data_transformers.disable_max_rows(): | ||
jsonfile = alt.data_transformers.get()(sample_data) | ||
except: | ||
jsonfile = {} | ||
finally: | ||
if jsonfile: | ||
os.remove(jsonfile['url']) |
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,33 @@ | ||
import os | ||
|
||
import pandas as pd | ||
import pytest | ||
|
||
from .. import data as alt | ||
|
||
|
||
@pytest.fixture | ||
def sample_data(): | ||
return pd.DataFrame({'x': range(10), 'y': range(10)}) | ||
|
||
|
||
def test_disable_max_rows(sample_data): | ||
with alt.data_transformers.enable('default', max_rows=5): | ||
# Ensure max rows error is raised. | ||
with pytest.raises(alt.MaxRowsError): | ||
alt.data_transformers.get()(sample_data) | ||
|
||
# Ensure that max rows error is properly disabled. | ||
with alt.data_transformers.disable_max_rows(): | ||
alt.data_transformers.get()(sample_data) | ||
|
||
try: | ||
with alt.data_transformers.enable('json'): | ||
# Ensure that there is no TypeError for non-max_rows transformers. | ||
with alt.data_transformers.disable_max_rows(): | ||
jsonfile = alt.data_transformers.get()(sample_data) | ||
except: | ||
jsonfile = {} | ||
finally: | ||
if jsonfile: | ||
os.remove(jsonfile['url']) |
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