File: test_metadata.py

package info (click to toggle)
python-vega-datasets 0.9%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,128 kB
  • sloc: python: 623; makefile: 22
file content (26 lines) | stat: -rw-r--r-- 935 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import pytest

from vega_datasets import data
from vega_datasets.core import Dataset


def test_metadata():
    all_datasets = Dataset.list_datasets()
    local_datasets = Dataset.list_local_datasets()
    for name in all_datasets:
        dataobj = getattr(data, name.replace("-", "_"))

        if name in local_datasets:
            # Local datasets should all have a description defined
            assert len(dataobj.description) > 0
            assert len(dataobj.filepath) > 0
        else:
            with pytest.raises(ValueError) as err:
                dataobj.filepath
            assert str(err.value) == "filepath is only valid for local datasets"

        # Descriptions should either be defined, or be None
        assert dataobj.description is None or len(dataobj.description) > 0

        # References should either be a list, or be None
        assert dataobj.references is None or type(dataobj.references) is list