danish-dynaword / tests /test_dataset_schema.py
KennethEnevoldsen's picture
added outlines for more tests
52178ed unverified
raw
history blame
1.86 kB
# from datetime import date
# from typing import Any
from pathlib import Path
# from pydantic import BaseModel
# # {
# # "text": "SAMLEDE VÆRKER\n\nJEPPE AAKJÆR GYLDENDALSKE BOGHANDEL...",
# # "source": "adl",
# # "id": "adl_aakjaer06val",
# # "added": "2020-09-14",
# # "created": "1700-01-01, 2022-01-01",
# # "license": "Creative Commons Legal Code\n\nCC0 1.0 Universal",
# # "domain": "Wiki & Books",
# # "metadata": {"source-pretty": "Archive for Danish Literature"},
# # }
# class SampleSchema(BaseModel):
# text: str
# source: str
# id: str
# added: date # date.fromisoformat
# created: tuple[date, date]
# license: str # TODO: should probably be a literal
# domain: str # TODO: convert to literal
# metadata: dict[str, Any]
# def metadata_validator(cls):
# assert "source-pretty" in cls.metadata
# def test_sample_schema():
# """Ensure that the dataset samples follow the correct schema"""
# pass
# def test_dataset_schema():
# """tests that the dataset frontmatter and markdown follows the correct format."""
# # test correct yaml
# # test it has place for descriptive stats
# # test license is specified in text in "other" is used.
# pass
def test_dataset_folder_structure(repo_path: Path):
"""tests that the dataset folder structure is as follows.
dataset_name
|- dataset_name.md
|- dataset_name.parquet
If there is a python file, there should at least be one called `create.py`, but there can be additional.
"""
datasets = (repo_path / "data").glob("*")
for path in datasets:
assert (path / f"{path.name}.parquet").exists()
assert (path / f"{path.name}.md").exists()
if any(p.name.endswith(".py") for p in path.glob("*")):
assert (path / "create.py").exists()