From 24e9fbdd44836eda49232804f7f65256705be237 Mon Sep 17 00:00:00 2001 From: Alex Parsons Date: Tue, 27 Aug 2024 09:59:19 +0000 Subject: [PATCH] Add readme tests --- .github/workflows/test.yml | 1 + README.md | 16 ++++++++---- poetry.lock | 52 +++++++++++++++++++++++++++++++++++++- pyproject.toml | 1 + 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dafaecc..920e92a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,7 @@ jobs: shell: bash run: | python -m pytest -v tests + python -m pytest --markdown-docs README.md - name: Test with ruff shell: bash diff --git a/README.md b/README.md index fefa0ea..b789236 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,9 @@ After first use, there is some caching behind the scenes to speed this up. from mysoc_validator import Popolo from mysoc_validator.models.popolo import Chamber, IdentifierScheme from datetime import date -popolo = Popolo.from_path() +popolo = Popolo.from_parlparse() -keir_starmer_parl_id = popolo.persons.from_identifier(4514, scheme=IdentifierScheme.MNIS) +keir_starmer_parl_id = popolo.persons.from_identifier("4514", scheme=IdentifierScheme.MNIS) keir_starmer_name = popolo.persons.from_name( "keir starmer", chamber_id=Chamber.COMMONS, date=date.fromisoformat("2022-07-31") ) @@ -56,8 +56,11 @@ Python validator and handler for 'publicwhip' style transcript format. ```python from mysoc_validator import Transcript +from pathlib import Path -transcript = Transcript.from_path() +transcript_file = Path("data", "debates2023-03-28d.xml") + +transcript = Transcript.from_xml_path(transcript_file) ``` ## Register of Interests @@ -65,8 +68,11 @@ transcript = Transcript.from_path() Python validator and handler for 'publicwhip' style interests format. ```python -from mysoc_validator import Registry +from mysoc_validator import Register +from pathlib import Path + +register_file = Path("data", "regmem2024-05-28.xml") +interests = Register.from_xml_path(register_file) -interests = Registry.from_path() ``` diff --git a/poetry.lock b/poetry.lock index 261501f..a388ccc 100644 --- a/poetry.lock +++ b/poetry.lock @@ -405,6 +405,41 @@ files = [ [package.extras] test = ["coverage[toml] (>=7.2.5)", "mypy (>=1.2.0)", "pytest (>=7.3.0)", "pytest-mypy-plugins (>=1.10.1)"] +[[package]] +name = "markdown-it-py" +version = "3.0.0" +description = "Python port of markdown-it. Markdown parsing, done right!" +optional = false +python-versions = ">=3.8" +files = [ + {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"}, + {file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"}, +] + +[package.dependencies] +mdurl = ">=0.1,<1.0" + +[package.extras] +benchmarking = ["psutil", "pytest", "pytest-benchmark"] +code-style = ["pre-commit (>=3.0,<4.0)"] +compare = ["commonmark (>=0.9,<1.0)", "markdown (>=3.4,<4.0)", "mistletoe (>=1.0,<2.0)", "mistune (>=2.0,<3.0)", "panflute (>=2.3,<3.0)"] +linkify = ["linkify-it-py (>=1,<3)"] +plugins = ["mdit-py-plugins"] +profiling = ["gprof2dot"] +rtd = ["jupyter_sphinx", "mdit-py-plugins", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"] +testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] + +[[package]] +name = "mdurl" +version = "0.1.2" +description = "Markdown URL utilities" +optional = false +python-versions = ">=3.7" +files = [ + {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, + {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, +] + [[package]] name = "nodeenv" version = "1.9.1" @@ -637,6 +672,21 @@ pytest = ">=4.6" [package.extras] testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] +[[package]] +name = "pytest-markdown-docs" +version = "0.5.1" +description = "Run markdown code fences through pytest" +optional = false +python-versions = ">=3.8,<4.0" +files = [ + {file = "pytest_markdown_docs-0.5.1-py3-none-any.whl", hash = "sha256:29849ae0fccb4dce27f86ee82d942a234095804d6f6ef6157473d38a6903aab3"}, + {file = "pytest_markdown_docs-0.5.1.tar.gz", hash = "sha256:acf9b678b589779e817f740bb1c8c4984a1bdca23ddc1c68ea6377918f5a871c"}, +] + +[package.dependencies] +markdown-it-py = ">=2.2.0,<4.0" +pytest = ">=7.0.0" + [[package]] name = "requests" version = "2.32.3" @@ -784,4 +834,4 @@ zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "240f90a8c19c8062d7e59ef6376ceddbd7a63295f6346cb1253f38419466a330" +content-hash = "3834bd3dcf429aedc2e643f985cdfcb670c044cf98e7f012544a6ea43cf21111" diff --git a/pyproject.toml b/pyproject.toml index 0334d04..fb29cf7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ pyright = "^1.1" toml = "^0.10.2" ruff = "^0.5.5" lxml-stubs = "^0.5.1" +pytest-markdown-docs = "^0.5.1" [build-system] requires = ["poetry-core>=1.0.0"]