diff --git a/.gitignore b/.gitignore index f0b1c72..fdbd054 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ src/xmltodict examples/data tests/tmp +.env diff --git a/poetry.lock b/poetry.lock index b021e2f..1c4accf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,9 +1,10 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry and should not be changed by hand. [[package]] name = "alabaster" version = "0.7.16" description = "A light, configurable Sphinx theme" +category = "main" optional = false python-versions = ">=3.9" files = [ @@ -15,6 +16,7 @@ files = [ name = "babel" version = "2.15.0" description = "Internationalization utilities" +category = "main" optional = false python-versions = ">=3.8" files = [ @@ -29,6 +31,7 @@ dev = ["freezegun (>=1.0,<2.0)", "pytest (>=6.0)", "pytest-cov"] name = "beautifulsoup4" version = "4.12.3" description = "Screen-scraping library" +category = "main" optional = false python-versions = ">=3.6.0" files = [ @@ -50,6 +53,7 @@ lxml = ["lxml"] name = "black" version = "24.4.2" description = "The uncompromising code formatter." +category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -96,6 +100,7 @@ uvloop = ["uvloop (>=0.15.2)"] name = "certifi" version = "2024.6.2" description = "Python package for providing Mozilla's CA Bundle." +category = "main" optional = false python-versions = ">=3.6" files = [ @@ -107,6 +112,7 @@ files = [ name = "charset-normalizer" version = "3.3.2" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." +category = "main" optional = false python-versions = ">=3.7.0" files = [ @@ -206,6 +212,7 @@ files = [ name = "click" version = "8.1.7" description = "Composable command line interface toolkit" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -220,6 +227,7 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""} name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." +category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -231,6 +239,7 @@ files = [ name = "commonmark" version = "0.9.1" description = "Python parser for the CommonMark Markdown spec" +category = "main" optional = false python-versions = "*" files = [ @@ -245,6 +254,7 @@ test = ["flake8 (==3.7.8)", "hypothesis (==3.55.3)"] name = "coverage" version = "7.5.3" description = "Code coverage measurement for Python" +category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -312,6 +322,7 @@ toml = ["tomli"] name = "docutils" version = "0.21.2" description = "Docutils -- Python Documentation Utilities" +category = "main" optional = false python-versions = ">=3.9" files = [ @@ -323,6 +334,7 @@ files = [ name = "exceptiongroup" version = "1.2.1" description = "Backport of PEP 654 (exception groups)" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -337,6 +349,7 @@ test = ["pytest (>=6)"] name = "flake8" version = "7.0.0" description = "the modular source code checker: pep8 pyflakes and co" +category = "dev" optional = false python-versions = ">=3.8.1" files = [ @@ -353,6 +366,7 @@ pyflakes = ">=3.2.0,<3.3.0" name = "furo" version = "2024.5.6" description = "A clean customisable Sphinx documentation theme." +category = "main" optional = false python-versions = ">=3.8" files = [ @@ -370,6 +384,7 @@ sphinx-basic-ng = ">=1.0.0.beta2" name = "idna" version = "3.7" description = "Internationalized Domain Names in Applications (IDNA)" +category = "main" optional = false python-versions = ">=3.5" files = [ @@ -381,6 +396,7 @@ files = [ name = "imagesize" version = "1.4.1" description = "Getting image size from png/jpeg/jpeg2000/gif file" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ @@ -392,6 +408,7 @@ files = [ name = "importlib-metadata" version = "7.1.0" description = "Read metadata from Python packages" +category = "main" optional = false python-versions = ">=3.8" files = [ @@ -411,6 +428,7 @@ testing = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" +category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -422,6 +440,7 @@ files = [ name = "isort" version = "5.13.2" description = "A Python utility / library to sort Python imports." +category = "dev" optional = false python-versions = ">=3.8.0" files = [ @@ -436,6 +455,7 @@ colors = ["colorama (>=0.4.6)"] name = "jinja2" version = "3.1.4" description = "A very fast and expressive template engine." +category = "main" optional = false python-versions = ">=3.7" files = [ @@ -453,6 +473,7 @@ i18n = ["Babel (>=2.7)"] name = "markupsafe" version = "2.1.5" description = "Safely add untrusted strings to HTML/XML markup." +category = "main" optional = false python-versions = ">=3.7" files = [ @@ -522,6 +543,7 @@ files = [ name = "mccabe" version = "0.7.0" description = "McCabe checker, plugin for flake8" +category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -533,6 +555,7 @@ files = [ name = "mypy-extensions" version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." +category = "dev" optional = false python-versions = ">=3.5" files = [ @@ -544,6 +567,7 @@ files = [ name = "numpy" version = "1.26.4" description = "Fundamental package for array computing in Python" +category = "main" optional = false python-versions = ">=3.9" files = [ @@ -589,6 +613,7 @@ files = [ name = "packaging" version = "24.0" description = "Core utilities for Python packages" +category = "main" optional = false python-versions = ">=3.7" files = [ @@ -600,6 +625,7 @@ files = [ name = "pandas" version = "2.2.2" description = "Powerful data structures for data analysis, time series, and statistics" +category = "main" optional = false python-versions = ">=3.9" files = [ @@ -673,6 +699,7 @@ xml = ["lxml (>=4.9.2)"] name = "pathspec" version = "0.12.1" description = "Utility library for gitignore style pattern matching of file paths." +category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -684,6 +711,7 @@ files = [ name = "platformdirs" version = "4.2.2" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." +category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -700,6 +728,7 @@ type = ["mypy (>=1.8)"] name = "pluggy" version = "1.5.0" description = "plugin and hook calling mechanisms for python" +category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -715,6 +744,7 @@ testing = ["pytest", "pytest-benchmark"] name = "pycodestyle" version = "2.11.1" description = "Python style guide checker" +category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -726,6 +756,7 @@ files = [ name = "pyflakes" version = "3.2.0" description = "passive checker of Python programs" +category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -737,6 +768,7 @@ files = [ name = "pygments" version = "2.18.0" description = "Pygments is a syntax highlighting package written in Python." +category = "main" optional = false python-versions = ">=3.8" files = [ @@ -751,6 +783,7 @@ windows-terminal = ["colorama (>=0.4.6)"] name = "pyrdfj2" version = "0.0.5" description = "Python wrapper on jinja SPARQL templating" +category = "main" optional = false python-versions = ">=3.8.1,<4.0" files = [] @@ -772,6 +805,7 @@ resolved_reference = "b131b5a8b070820a1498135760e2ea427990b695" name = "pytest" version = "8.2.1" description = "pytest: simple powerful testing with Python" +category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -794,6 +828,7 @@ dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments name = "pytest-cov" version = "5.0.0" description = "Pytest plugin for measuring coverage." +category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -812,6 +847,7 @@ testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] name = "python-dateutil" version = "2.9.0.post0" description = "Extensions to the standard Python datetime module" +category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ @@ -826,6 +862,7 @@ six = ">=1.5" name = "python-dotenv" version = "1.0.1" description = "Read key-value pairs from a .env file and set them as environment variables" +category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -840,6 +877,7 @@ cli = ["click (>=5.0)"] name = "pytz" version = "2024.1" description = "World timezone definitions, modern and historical" +category = "main" optional = false python-versions = "*" files = [ @@ -851,6 +889,7 @@ files = [ name = "pyyaml" version = "6.0.1" description = "YAML parser and emitter for Python" +category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -872,6 +911,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -910,6 +950,7 @@ files = [ name = "recommonmark" version = "0.7.1" description = "A docutils-compatibility bridge to CommonMark, enabling you to write CommonMark inside of Docutils & Sphinx projects." +category = "main" optional = false python-versions = "*" files = [ @@ -926,6 +967,7 @@ sphinx = ">=1.3.1" name = "requests" version = "2.32.3" description = "Python HTTP for Humans." +category = "main" optional = false python-versions = ">=3.8" files = [ @@ -947,6 +989,7 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" files = [ @@ -958,6 +1001,7 @@ files = [ name = "snowballstemmer" version = "2.2.0" description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." +category = "main" optional = false python-versions = "*" files = [ @@ -969,6 +1013,7 @@ files = [ name = "soupsieve" version = "2.5" description = "A modern CSS selector implementation for Beautiful Soup." +category = "main" optional = false python-versions = ">=3.8" files = [ @@ -980,6 +1025,7 @@ files = [ name = "sphinx" version = "7.3.7" description = "Python documentation generator" +category = "main" optional = false python-versions = ">=3.9" files = [ @@ -1016,6 +1062,7 @@ test = ["cython (>=3.0)", "defusedxml (>=0.7.1)", "pytest (>=6.0)", "setuptools name = "sphinx-basic-ng" version = "1.0.0b2" description = "A modern skeleton for Sphinx themes." +category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1033,6 +1080,7 @@ docs = ["furo", "ipython", "myst-parser", "sphinx-copybutton", "sphinx-inline-ta name = "sphinxcontrib-applehelp" version = "1.0.8" description = "sphinxcontrib-applehelp is a Sphinx extension which outputs Apple help books" +category = "main" optional = false python-versions = ">=3.9" files = [ @@ -1049,6 +1097,7 @@ test = ["pytest"] name = "sphinxcontrib-devhelp" version = "1.0.6" description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp documents" +category = "main" optional = false python-versions = ">=3.9" files = [ @@ -1065,6 +1114,7 @@ test = ["pytest"] name = "sphinxcontrib-htmlhelp" version = "2.0.5" description = "sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files" +category = "main" optional = false python-versions = ">=3.9" files = [ @@ -1081,6 +1131,7 @@ test = ["html5lib", "pytest"] name = "sphinxcontrib-jsmath" version = "1.0.1" description = "A sphinx extension which renders display math in HTML via JavaScript" +category = "main" optional = false python-versions = ">=3.5" files = [ @@ -1095,6 +1146,7 @@ test = ["flake8", "mypy", "pytest"] name = "sphinxcontrib-qthelp" version = "1.0.7" description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp documents" +category = "main" optional = false python-versions = ">=3.9" files = [ @@ -1111,6 +1163,7 @@ test = ["pytest"] name = "sphinxcontrib-serializinghtml" version = "1.1.10" description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)" +category = "main" optional = false python-versions = ">=3.9" files = [ @@ -1127,6 +1180,7 @@ test = ["pytest"] name = "tomli" version = "2.0.1" description = "A lil' TOML parser" +category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1138,6 +1192,7 @@ files = [ name = "typeguard" version = "4.3.0" description = "Run-time type checker for Python" +category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1157,6 +1212,7 @@ test = ["coverage[toml] (>=7)", "mypy (>=1.2.0)", "pytest (>=7)"] name = "typing-extensions" version = "4.12.1" description = "Backported and Experimental Type Hints for Python 3.8+" +category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1168,6 +1224,7 @@ files = [ name = "tzdata" version = "2024.1" description = "Provider of IANA time zone data" +category = "main" optional = false python-versions = ">=2" files = [ @@ -1179,6 +1236,7 @@ files = [ name = "uritemplate" version = "4.1.1" description = "Implementation of RFC 6570 URI Templates" +category = "main" optional = false python-versions = ">=3.6" files = [ @@ -1190,6 +1248,7 @@ files = [ name = "urllib3" version = "2.2.1" description = "HTTP library with thread-safe connection pooling, file post, and more." +category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1207,6 +1266,7 @@ zstd = ["zstandard (>=0.18.0)"] name = "validators" version = "0.28.3" description = "Python Data Validation for Humans™" +category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1218,6 +1278,7 @@ files = [ name = "xmlasdict" version = "0.2.2" description = "python library to read xml DOM trees as dicts (with iter and gettattribute behaviour)" +category = "main" optional = false python-versions = "*" files = [ @@ -1229,6 +1290,7 @@ files = [ name = "zipp" version = "3.19.1" description = "Backport of pathlib-compatible object wrapper for zip files" +category = "main" optional = false python-versions = ">=3.8" files = [ diff --git a/tests/test_conditional.py b/tests/test_conditional.py index 0d84efd..38eb66f 100644 --- a/tests/test_conditional.py +++ b/tests/test_conditional.py @@ -3,7 +3,7 @@ import unittest from pathlib import Path -import pandas as pd +from util4tests import log, run_single_test from pysubyt import Subyt @@ -20,6 +20,8 @@ def test_conditional(self): if Path("./tests/tmp/data/D.ttl").exists(): os.remove("./tests/tmp/data/D.ttl") + data_mtime0 = os.stat("./tests/resources/data.csv").st_mtime + # first run Subyt( source="./tests/resources/data.csv", @@ -29,6 +31,7 @@ def test_conditional(self): conditional=True, ).process() A_mtime1 = os.stat("./tests/tmp/data/A.ttl").st_mtime + log.debug(f"A.ttl exists and lastmod at {A_mtime1}") # second run and no updates to input file time.sleep(1) @@ -40,13 +43,17 @@ def test_conditional(self): conditional=True, ).process() A_mtime2 = os.stat("./tests/tmp/data/A.ttl").st_mtime - assert A_mtime1 == A_mtime2 # output file should not have been updated + assert A_mtime1 == A_mtime2, "A.ttl output should not been updated" + log.debug(f"A.ttl lastmod still at {A_mtime2}") # third run and update to input file + Path("./tests/resources/data.csv").touch() + data_mtime3 = os.stat("./tests/resources/data.csv").st_mtime + log.debug(f"data.csv updated at {data_mtime3}") + assert data_mtime0 < data_mtime3, "data file not updated" + assert A_mtime1 < data_mtime3, "data still older then last output" time.sleep(1) - df = pd.read_csv("./tests/resources/data.csv") - df.at[0, "value"] = 0 - df.to_csv("./tests/resources/data.csv", index=False) + Subyt( source="./tests/resources/data.csv", sink="./tests/tmp/data/{key}.ttl", @@ -55,7 +62,11 @@ def test_conditional(self): conditional=True, ).process() A_mtime3 = os.stat("./tests/tmp/data/A.ttl").st_mtime - assert A_mtime1 < A_mtime3 # output file should have been updated + assert A_mtime1 < A_mtime3, "A.ttl output should been updated" + assert data_mtime3 < A_mtime3, ( + "A.ttl output file should be newer then data input" + f"{data_mtime3} < {A_mtime3}" + ) # fourth run and no updates to input file time.sleep(1) @@ -68,7 +79,7 @@ def test_conditional(self): ).process() A_mtime4 = os.stat("./tests/tmp/data/A.ttl").st_mtime D_mtime4 = os.stat("./tests/tmp/data/D.ttl").st_mtime - assert A_mtime3 == A_mtime4 # output file should not have been updated + assert A_mtime3 == A_mtime4, "A.ttl output should not been updated" # fifth run and one of the output files is missing time.sleep(1) @@ -82,10 +93,9 @@ def test_conditional(self): ).process() A_mtime5 = os.stat("./tests/tmp/data/A.ttl").st_mtime D_mtime5 = os.stat("./tests/tmp/data/D.ttl").st_mtime - assert A_mtime4 == A_mtime5 # output file should not have been updated - assert D_mtime4 < D_mtime5 # output file should have been updated + assert A_mtime4 == A_mtime5, "A.ttl output should not been updated" + assert D_mtime4 < D_mtime5, "D.ttl output should been updated" + - # reset input file - df = pd.read_csv("./tests/resources/data.csv") - df.at[0, "value"] = 1 - df.to_csv("./tests/resources/data.csv", index=False) +if __name__ == "__main__": + run_single_test(__file__)