|
| 1 | +"""Tests for release information.""" |
| 2 | + |
| 3 | +from importlib.resources import files |
| 4 | +from pathlib import Path |
| 5 | + |
| 6 | +import tomli |
| 7 | + |
| 8 | +package_root = Path(files("autotuning_methodology")).parent.parent |
| 9 | +pyproject_toml_path = package_root / "pyproject.toml" |
| 10 | +assert pyproject_toml_path.exists() |
| 11 | +with open(pyproject_toml_path, mode="rb") as fp: |
| 12 | + pyproject = tomli.load(fp) |
| 13 | + |
| 14 | + |
| 15 | +def test_read(): |
| 16 | + """Test whether the contents have been read correctly and the required keys are in place.""" |
| 17 | + assert isinstance(pyproject, dict) |
| 18 | + assert "build-system" in pyproject |
| 19 | + assert "project" in pyproject |
| 20 | + |
| 21 | + |
| 22 | +def test_name(): |
| 23 | + """Ensure the name is consistent.""" |
| 24 | + assert "name" in pyproject["project"] |
| 25 | + assert pyproject["project"]["name"] == "autotuning_methodology" |
| 26 | + |
| 27 | + |
| 28 | +def test_versioning(): |
| 29 | + """Test whether the versioning is PEP440 compliant.""" |
| 30 | + from pep440 import is_canonical |
| 31 | + |
| 32 | + assert "version" in pyproject["project"] |
| 33 | + assert is_canonical(pyproject["project"]["version"]) |
| 34 | + |
| 35 | + |
| 36 | +def test_authors(): |
| 37 | + """Ensure the authors are specified.""" |
| 38 | + assert "authors" in pyproject["project"] |
| 39 | + assert len(pyproject["project"]["authors"]) > 0 |
| 40 | + |
| 41 | + |
| 42 | +def test_license(): |
| 43 | + """Ensure the license is set and the file exists.""" |
| 44 | + assert "license" in pyproject["project"] |
| 45 | + license = pyproject["project"]["license"] |
| 46 | + assert len(license) > 0 |
| 47 | + assert license["file"] == "LICENSE" |
| 48 | + assert Path(package_root / "LICENSE").exists() |
| 49 | + |
| 50 | + |
| 51 | +def test_readme(): |
| 52 | + """Ensure the readme is set and the file exists.""" |
| 53 | + assert "readme" in pyproject["project"] |
| 54 | + readme = pyproject["project"]["readme"] |
| 55 | + assert len(readme) > 0 |
| 56 | + assert Path(package_root / readme).exists() |
| 57 | + |
| 58 | + |
| 59 | +def test_project_keys(): |
| 60 | + """Check whether the expected keys in [project] are present.""" |
| 61 | + project = pyproject["project"] |
| 62 | + assert "description" in project |
| 63 | + assert "keywords" in project |
| 64 | + assert "classifiers" in project |
| 65 | + assert "dependencies" in project |
| 66 | + assert "requires-python" in project |
0 commit comments