| 1 | import pytest |
| 2 | |
| 3 | from vega_datasets import data, local_data |
| 4 | from vega_datasets.core import Dataset |
| 5 | |
| 6 | |
| 7 | def test_undefined_dataset(): |
| 8 | with pytest.raises(AttributeError) as err: |
| 9 | data("blahblahblah") |
| 10 | assert str(err.value) == "No dataset named 'blahblahblah'" |
| 11 | with pytest.raises(AttributeError) as err: |
| 12 | local_data("blahblahblah") |
| 13 | assert str(err.value) == "No dataset named 'blahblahblah'" |
| 14 | |
| 15 | |
| 16 | def test_undefined_infodict(): |
| 17 | with pytest.raises(ValueError) as err: |
| 18 | Dataset._infodict("blahblahblah") |
| 19 | assert str(err.value).startswith("No such dataset blahblahblah exists") |
| 20 | |
| 21 | |
| 22 | @pytest.mark.parametrize( |
| 23 | "name", (set(Dataset.list_datasets()) - set(Dataset.list_local_datasets())) |
| 24 | ) |
| 25 | def test_local_dataset_error(name): |
| 26 | with pytest.raises(ValueError) as err: |
| 27 | local_data(name) |
| 28 | assert str(err.value).startswith( |
| 29 | "'{0}' dataset is not available locally" "".format(name.replace("-", "_")) |
| 30 | ) |