From 779c8fbc2f1161a8ef3b3ea33d33395fa7d5250d Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sat, 11 Apr 2020 13:28:22 -0600 Subject: [PATCH] Test Version match (#887) * [Tests] makes sure `--version` works Directly reads the version number from pyproject.toml * Tag the tests To run just this test, use `behave --tags=deployments_tests` --- features/regression.feature | 7 +++++++ features/steps/core.py | 11 +++++++++++ poetry.lock | 2 +- pyproject.toml | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/features/regression.feature b/features/regression.feature index 5aa1db06..4dc35b5a 100644 --- a/features/regression.feature +++ b/features/regression.feature @@ -122,3 +122,10 @@ Feature: Zapped bugs should stay dead. Then the output should contain "This thing happened yesterday" Then the output should contain "Adding an entry right now." Then the output should not contain "A future entry." + + @deployment_tests + Scenario: Version numbers should stay in sync + Given we use the config "basic.yaml" + When we run "jrnl --version" + Then we should get no error + Then the output should contain pyproject.toml version diff --git a/features/steps/core.py b/features/steps/core.py index 36b6573a..6eebd575 100644 --- a/features/steps/core.py +++ b/features/steps/core.py @@ -19,6 +19,8 @@ import keyring import tzlocal import shlex import sys +from pathlib import Path +import toml consts = pdt.Constants(usePyICU=False) consts.DOWParseStyle = -1 # Prefers past weekdays @@ -207,6 +209,15 @@ def check_output_time_inline(context, text): assert output_date in out, output_date +@then("the output should contain pyproject.toml version") +def check_output_version_inline(context): + out = context.stdout_capture.getvalue() + pyproject = (Path(__file__) / ".." / ".." / ".." / "pyproject.toml").resolve() + pyproject_contents = toml.load(pyproject) + pyproject_version = pyproject_contents["tool"]["poetry"]["version"] + assert pyproject_version in out, pyproject_version + + @then("the output should contain") @then('the output should contain "{text}"') @then('the output should contain "{text}" or "{text2}"') diff --git a/poetry.lock b/poetry.lock index 65356424..88eb5b3f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -522,7 +522,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] testing = ["jaraco.itertools", "func-timeout"] [metadata] -content-hash = "17cf8d4cf5a772217160daf312f590901dea4a3f5545d003035f3fb713a70f07" +content-hash = "afeb906a1ba51bc9fc4e8c19c0b2c63bb5c9529697c9496d6edb64b509da9e0f" python-versions = ">=3.6.0, <3.9.0" [metadata.files] diff --git a/pyproject.toml b/pyproject.toml index 20f2c306..2a52a7e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ behave = "^1.2" mkdocs = "^1.0" flake8 = "^3.7" black = {version = "^19.10b0",allow-prereleases = true} +toml = "^0.10.0" [tool.poetry.scripts] jrnl = 'jrnl.cli:run'