Debian Codegraph @

vega_datasets/tests/test_metadata.py

raw symbols SCIP
1 import pytest
2
3 from vega_datasets import data
4 from vega_datasets.core import Dataset
5
6
7 def test_metadata():
8 all_datasets = Dataset.list_datasets()
9 local_datasets = Dataset.list_local_datasets()
10 for name in all_datasets:
11 dataobj = getattr(data, name.replace("-", "_"))
12
13 if name in local_datasets:
14 # Local datasets should all have a description defined
15 assert len(dataobj.description) > 0
16 assert len(dataobj.filepath) > 0
17 else:
18 with pytest.raises(ValueError) as err:
19 dataobj.filepath
20 assert str(err.value) == "filepath is only valid for local datasets"
21
22 # Descriptions should either be defined, or be None
23 assert dataobj.description is None or len(dataobj.description) > 0
24
25 # References should either be a list, or be None
26 assert dataobj.references is None or type(dataobj.references) is list