From eed2038e63a5ce1e96f9969f152c13acf31cbbf3 Mon Sep 17 00:00:00 2001 From: Ethan Paul <24588726+enpaul@users.noreply.github.com> Date: Thu, 24 Sep 2020 21:06:54 -0400 Subject: [PATCH] Add trivial tests to ensure metadata consistency between pyroject and module --- tests/test_metadata.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/test_metadata.py diff --git a/tests/test_metadata.py b/tests/test_metadata.py new file mode 100644 index 0000000..eaa4bf1 --- /dev/null +++ b/tests/test_metadata.py @@ -0,0 +1,39 @@ +"""Ensure that the pyproject and module metadata never drift out of sync + +The next best thing to having one source of truth is having a way to ensure all of your +sources of truth agree with each other. +""" +from pathlib import Path + +import toml + +import tox_poetry_installer + + +def test_metadata(): + """Test that module metadata matches pyproject poetry metadata""" + + with (Path(__file__).resolve().parent / ".." / "pyproject.toml").open() as infile: + pyproject = toml.load(infile, _dict=dict) + + assert pyproject["tool"]["poetry"]["name"] == tox_poetry_installer.__title__ + assert pyproject["tool"]["poetry"]["version"] == tox_poetry_installer.__version__ + assert pyproject["tool"]["poetry"]["license"] == tox_poetry_installer.__license__ + assert ( + pyproject["tool"]["poetry"]["description"] == tox_poetry_installer.__summary__ + ) + assert pyproject["tool"]["poetry"]["repository"] == tox_poetry_installer.__url__ + assert ( + all( + item in tox_poetry_installer.__authors__ + for item in pyproject["tool"]["poetry"]["authors"] + ) + is True + ) + assert ( + all( + item in pyproject["tool"]["poetry"]["authors"] + for item in tox_poetry_installer.__authors__ + ) + is True + )