From 772ab1ad81d7df6c6bfd1f27ab9fa340d1c46d1c Mon Sep 17 00:00:00 2001 From: Sebastien Rousseau Date: Sun, 19 May 2024 18:37:31 +0100 Subject: [PATCH] chore(pain001): :arrow_up: upgrading dependencies and sync --- poetry.lock | 73 +++++++++++++++++++------------------- pyproject.toml | 32 ++++++++--------- requirements.txt | 44 +++++++++++++++++++++-- setup.cfg | 52 ++++++++++++++++++++++----- tests/test_load_db_data.py | 48 +++++++++++++++++++++++++ 5 files changed, 185 insertions(+), 64 deletions(-) create mode 100644 tests/test_load_db_data.py diff --git a/poetry.lock b/poetry.lock index 8143623..1f82957 100644 --- a/poetry.lock +++ b/poetry.lock @@ -255,13 +255,13 @@ files = [ [[package]] name = "docutils" -version = "0.19" +version = "0.21.2" description = "Docutils -- Python Documentation Utilities" optional = false -python-versions = ">=3.7" +python-versions = ">=3.9" files = [ - {file = "docutils-0.19-py3-none-any.whl", hash = "sha256:5e1de4d849fee02c63b040a4a3fd567f4ab104defd8a5511fbbc24a8a017efbc"}, - {file = "docutils-0.19.tar.gz", hash = "sha256:33995a6753c30b7f577febfc2c50411fec6aac7f7ffeb7c4cfe5991072dcf9e6"}, + {file = "docutils-0.21.2-py3-none-any.whl", hash = "sha256:dafca5b9e384f0e419294eb4d2ff9fa826435bf15f15b7bd45723e8ad76811b2"}, + {file = "docutils-0.21.2.tar.gz", hash = "sha256:3a6b18732edf182daa3cd12775bbb338cf5691468f91eeeb109deff6ebfa986f"}, ] [[package]] @@ -507,13 +507,13 @@ windows-terminal = ["colorama (>=0.4.6)"] [[package]] name = "pytest" -version = "7.4.4" +version = "8.2.0" description = "pytest: simple powerful testing with Python" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"}, - {file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"}, + {file = "pytest-8.2.0-py3-none-any.whl", hash = "sha256:1733f0620f6cda4095bbf0d9ff8022486e91892245bb9e7d5542c018f612f233"}, + {file = "pytest-8.2.0.tar.gz", hash = "sha256:d507d4482197eac0ba2bae2e9babf0672eb333017bcedaa5fb1a3d42c1174b3f"}, ] [package.dependencies] @@ -521,21 +521,21 @@ colorama = {version = "*", markers = "sys_platform == \"win32\""} exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} iniconfig = "*" packaging = "*" -pluggy = ">=0.12,<2.0" -tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} +pluggy = ">=1.5,<2.0" +tomli = {version = ">=1", markers = "python_version < \"3.11\""} [package.extras] -testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] [[package]] name = "pytest-cov" -version = "3.0.0" +version = "5.0.0" description = "Pytest plugin for measuring coverage." optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "pytest-cov-3.0.0.tar.gz", hash = "sha256:e7f0f5b1617d2210a2cabc266dfe2f4c75a8d32fb89eafb7ad9d06f6d076d470"}, - {file = "pytest_cov-3.0.0-py3-none-any.whl", hash = "sha256:578d5d15ac4a25e5f961c938b85a05b09fdaae9deef3bb6de9a6e766622ca7a6"}, + {file = "pytest-cov-5.0.0.tar.gz", hash = "sha256:5837b58e9f6ebd335b0f8060eecce69b662415b16dc503883a02f45dfeb14857"}, + {file = "pytest_cov-5.0.0-py3-none-any.whl", hash = "sha256:4f0764a1219df53214206bf1feea4633c3b558a2925c8b59f144f682861ce652"}, ] [package.dependencies] @@ -543,7 +543,7 @@ coverage = {version = ">=5.2.1", extras = ["toml"]} pytest = ">=4.6" [package.extras] -testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] +testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] [[package]] name = "pytz" @@ -624,38 +624,39 @@ files = [ [[package]] name = "sphinx" -version = "5.3.0" +version = "7.3.7" description = "Python documentation generator" optional = false -python-versions = ">=3.6" +python-versions = ">=3.9" files = [ - {file = "Sphinx-5.3.0.tar.gz", hash = "sha256:51026de0a9ff9fc13c05d74913ad66047e104f56a129ff73e174eb5c3ee794b5"}, - {file = "sphinx-5.3.0-py3-none-any.whl", hash = "sha256:060ca5c9f7ba57a08a1219e547b269fadf125ae25b06b9fa7f66768efb652d6d"}, + {file = "sphinx-7.3.7-py3-none-any.whl", hash = "sha256:413f75440be4cacf328f580b4274ada4565fb2187d696a84970c23f77b64d8c3"}, + {file = "sphinx-7.3.7.tar.gz", hash = "sha256:a4a7db75ed37531c05002d56ed6948d4c42f473a36f46e1382b0bd76ca9627bc"}, ] [package.dependencies] -alabaster = ">=0.7,<0.8" +alabaster = ">=0.7.14,<0.8.0" babel = ">=2.9" colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} -docutils = ">=0.14,<0.20" +docutils = ">=0.18.1,<0.22" imagesize = ">=1.3" importlib-metadata = {version = ">=4.8", markers = "python_version < \"3.10\""} Jinja2 = ">=3.0" packaging = ">=21.0" -Pygments = ">=2.12" -requests = ">=2.5.0" +Pygments = ">=2.14" +requests = ">=2.25.0" snowballstemmer = ">=2.0" sphinxcontrib-applehelp = "*" sphinxcontrib-devhelp = "*" sphinxcontrib-htmlhelp = ">=2.0.0" sphinxcontrib-jsmath = "*" sphinxcontrib-qthelp = "*" -sphinxcontrib-serializinghtml = ">=1.1.5" +sphinxcontrib-serializinghtml = ">=1.1.9" +tomli = {version = ">=2", markers = "python_version < \"3.11\""} [package.extras] docs = ["sphinxcontrib-websupport"] -lint = ["docutils-stubs", "flake8 (>=3.5.0)", "flake8-bugbear", "flake8-comprehensions", "flake8-simplify", "isort", "mypy (>=0.981)", "sphinx-lint", "types-requests", "types-typed-ast"] -test = ["cython", "html5lib", "pytest (>=4.6)", "typed_ast"] +lint = ["flake8 (>=3.5.0)", "importlib_metadata", "mypy (==1.9.0)", "pytest (>=6.0)", "ruff (==0.3.7)", "sphinx-lint", "tomli", "types-docutils", "types-requests"] +test = ["cython (>=3.0)", "defusedxml (>=0.7.1)", "pytest (>=6.0)", "setuptools (>=67.0)"] [[package]] name = "sphinxcontrib-applehelp" @@ -781,22 +782,22 @@ zstd = ["zstandard (>=0.18.0)"] [[package]] name = "xmlschema" -version = "2.5.1" +version = "3.3.1" description = "An XML Schema validator and decoder" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "xmlschema-2.5.1-py3-none-any.whl", hash = "sha256:ec2b2a15c8896c1fcd14dcee34ca30032b99456c3c43ce793fdb9dca2fb4b869"}, - {file = "xmlschema-2.5.1.tar.gz", hash = "sha256:4f7497de6c8b6dc2c28ad7b9ed6e21d186f4afe248a5bea4f54eedab4da44083"}, + {file = "xmlschema-3.3.1-py3-none-any.whl", hash = "sha256:93547e999896f1525a821e229991d31e4dd02563f93b0667ce6566cf2b853751"}, + {file = "xmlschema-3.3.1.tar.gz", hash = "sha256:2066ecbc9728112073f6f44d17c5c16723aff1c7d22a7c4c6421e2d68ec5f0ea"}, ] [package.dependencies] -elementpath = ">=4.1.5,<5.0.0" +elementpath = ">=4.4.0,<5.0.0" [package.extras] -codegen = ["elementpath (>=4.1.5,<5.0.0)", "jinja2"] -dev = ["Sphinx", "coverage", "elementpath (>=4.1.5,<5.0.0)", "flake8", "jinja2", "lxml", "lxml-stubs", "memory-profiler", "mypy", "sphinx-rtd-theme", "tox"] -docs = ["Sphinx", "elementpath (>=4.1.5,<5.0.0)", "jinja2", "sphinx-rtd-theme"] +codegen = ["elementpath (>=4.4.0,<5.0.0)", "jinja2"] +dev = ["Sphinx", "coverage", "elementpath (>=4.4.0,<5.0.0)", "flake8", "jinja2", "lxml", "lxml-stubs", "memory-profiler", "mypy", "sphinx-rtd-theme", "tox"] +docs = ["Sphinx", "elementpath (>=4.4.0,<5.0.0)", "jinja2", "sphinx-rtd-theme"] [[package]] name = "zipp" @@ -861,4 +862,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "00fb3afe185721e06c07be876d4d31c44906f91477f408626819aa9dbe212179" +content-hash = "3d6e44a3939706e8dcf547f5b6aeba53219ac653aae4bbc930ed951e5277ab90" diff --git a/pyproject.toml b/pyproject.toml index e725fa8..b94a2a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,29 +9,29 @@ repository = "https://github.com/sebastienrousseau/pain001" homepage = "https://pain001.com" [tool.poetry.dependencies] -click = "^8.1.7" -colorama = "^0.4.6" -defusedxml = "^0.7.1" -elementpath = "^4.1.5" -jinja2 = "^3.1.4" -markdown-it-py = "^3.0.0" -markupsafe = "^2.1.3" -mdurl = "^0.1.2" -pygments = "^2.16.1" +click = "8.1.7" +colorama = "0.4.6" +datetime = "5.5" +defusedxml = "0.7.1" +elementpath = "4.4.0" +jinja2 = "3.1.4" +markdown-it-py = "3.0.0" +markupsafe = "2.1.5" +mdurl = "0.1.2" +pygments = "2.18.0" python = "^3.9" -rich = "^13.5.2" -xmlschema = "^2.4.0" +rich = "13.7.1" +xmlschema = "3.3.1" -# Dependency groups are supported for organizing your dependencies -datetime = "^5.5" [tool.poetry.group.dev.dependencies] -pytest = "^7.1.2" -pytest-cov = "^3.0" +pytest = "^8.1.0" +pytest-cov = "^5.0.0" [tool.poetry.group.docs] optional = true + [tool.poetry.group.docs.dependencies] -Sphinx = "^5.1.1" +Sphinx = "^7.3.7" [build-system] requires = ["poetry-core"] diff --git a/requirements.txt b/requirements.txt index fb749b6..54375aa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,9 @@ click==8.1.7 ; python_version >= "3.9" and python_version < "4.0" \ colorama==0.4.6 ; python_version >= "3.9" and python_version < "4.0" \ --hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \ --hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6 +datetime==5.5 ; python_version >= "3.9" and python_version < "4.0" \ + --hash=sha256:0abf6c51cb4ba7cee775ca46ccc727f3afdde463be28dbbe8803631fefd4a120 \ + --hash=sha256:21ec6331f87a7fcb57bd7c59e8a68bfffe6fcbf5acdbbc7b356d6a9a020191d3 defusedxml==0.7.1 ; python_version >= "3.9" and python_version < "4.0" \ --hash=sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69 \ --hash=sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61 @@ -83,9 +86,44 @@ mdurl==0.1.2 ; python_version >= "3.9" and python_version < "4.0" \ pygments==2.18.0 ; python_version >= "3.9" and python_version < "4.0" \ --hash=sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199 \ --hash=sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a +pytz==2024.1 ; python_version >= "3.9" and python_version < "4.0" \ + --hash=sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812 \ + --hash=sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319 rich==13.7.1 ; python_version >= "3.9" and python_version < "4.0" \ --hash=sha256:4edbae314f59eb482f54e9e30bf00d33350aaa94f4bfcd4e9e3110e64d0d7222 \ --hash=sha256:9be308cb1fe2f1f57d67ce99e95af38a1e2bc71ad9813b0e247cf7ffbcc3a432 -xmlschema==2.5.1 ; python_version >= "3.9" and python_version < "4.0" \ - --hash=sha256:4f7497de6c8b6dc2c28ad7b9ed6e21d186f4afe248a5bea4f54eedab4da44083 \ - --hash=sha256:ec2b2a15c8896c1fcd14dcee34ca30032b99456c3c43ce793fdb9dca2fb4b869 +setuptools==69.5.1 ; python_version >= "3.9" and python_version < "4.0" \ + --hash=sha256:6c1fccdac05a97e598fb0ae3bbed5904ccb317337a51139dcd51453611bbb987 \ + --hash=sha256:c636ac361bc47580504644275c9ad802c50415c7522212252c033bd15f301f32 +xmlschema==3.3.1 ; python_version >= "3.9" and python_version < "4.0" \ + --hash=sha256:2066ecbc9728112073f6f44d17c5c16723aff1c7d22a7c4c6421e2d68ec5f0ea \ + --hash=sha256:93547e999896f1525a821e229991d31e4dd02563f93b0667ce6566cf2b853751 +zope-interface==6.4 ; python_version >= "3.9" and python_version < "4.0" \ + --hash=sha256:21732994aa3ca43bbb6b36335c288023428a3c5b7322b637c7b0a03053937578 \ + --hash=sha256:36ee6e507a9fd4f1f0aab8e8dfc801d162e7211c27503cbfb47e1d558941a7fa \ + --hash=sha256:3945f4fda92c1b6fb0cb6eaaaf72599e5c2c2059654bdc42bc09c6e711c214c8 \ + --hash=sha256:414e6dccdf4a5c96c0c98da68ba040dbf9ba7511b61b34e228f11b0ed90c439d \ + --hash=sha256:4782e173c2fde4f649c2a9a68082445bc1f2c27f41907de06bf1ba82585847f2 \ + --hash=sha256:4cd56eb9a23767958c9a0654306b9a4a74def485f645b3a7378cc6ab661ef31c \ + --hash=sha256:502d2c9c4231d022b20225dba5c6c736236ed65e1d7e2f6f402b5aa6a7040ec9 \ + --hash=sha256:57f34b7997f8de7d2db08363eaccd05dad20f106e39efe95bed4fac84af2d022 \ + --hash=sha256:5fbbb290751f5c4ed81e54ae73fe8557c4a85973f5ab019edbb0f746244ecea6 \ + --hash=sha256:604fa920478dfc0c76cdb7c203572400a8317ffcdac288245c408b42b3d9aee9 \ + --hash=sha256:62e6b756663deade5270f67899753437b39d970f9eecd49e19fae3b880310cf0 \ + --hash=sha256:646cd83d24065d074f22f61fe101d20dbf4b729ca7831cc782ec986eb9156f93 \ + --hash=sha256:6494dc0314e782ce4fb0e624b4ce2458f54d074382f50a920c7700c05cbcef28 \ + --hash=sha256:6e4cc017206c1429a6d8fdd8a25c6efc15512065eec0a8d45c350df96a0911ed \ + --hash=sha256:72faa868fcfde49a29d287dce3c83180322467eecd725dd351098efe96e8d4bb \ + --hash=sha256:7cda82ab32f984985f09e4ec20a4f9665b26779a1b8e443b34a148de256f2052 \ + --hash=sha256:855b7233fa5d0d1f3be8c14fadf4718dee1c928e1d75f1584bea6ecec6dcc4af \ + --hash=sha256:86e85eada0eb551950df05d72dc0e892320f14daa78bc434059e834d4b1f9300 \ + --hash=sha256:8e246357f52952ae5fa950d19eda8572594c49e6cb1e5462508e6cec561a37de \ + --hash=sha256:93f28d84517dcd6c240979bd9b2f262a373832baef856fe663a24b9171d7f04d \ + --hash=sha256:b0f61ccbc26e08031d0e72b6a0cbf9b4030f035913cb2b39f940aa42eb8e0063 \ + --hash=sha256:b11f2b67ccc990a1522fa8cd3f5d185a068459f944ab2d0e7a1b15d31bcb4af4 \ + --hash=sha256:c04bd4ee4766d285e83c6d8c042663a98efb934389e05ccd643fefb066c88a9d \ + --hash=sha256:ee1e3ca6c98efe213a96dece89100a8aa52e210ac354861d8039d69bd1d6e5ff \ + --hash=sha256:f33af86ed460eb28dc9da1de1f3305795271a19c665161c1d973a737596b2081 \ + --hash=sha256:f5092f2712e1fd07579fc3101b18e9c95857c853e836847598bf992c8e672434 \ + --hash=sha256:f78e1eac48c4f4e0168a91cabcd8d1aedb972836df5c8769071fc6173294a0a3 \ + --hash=sha256:fe636b49c333bfc5b0913590e36a2f151167c462fb36d9f4acc66029e45c974b diff --git a/setup.cfg b/setup.cfg index 72ccad2..733b31f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,29 +15,63 @@ # limitations under the License. [metadata] +author = "Sebastien Rousseau " +description = "Pain001 is a Python Library for Automating ISO 20022-Compliant Payment Files Using CSV Data." +license = "Apache Software License" name = pain001 version = 0.0.25 [options] +packages = find: +include_package_data = true install_requires = click==8.1.7 colorama==0.4.6 + datetime==5.5 defusedxml==0.7.1 - elementpath==4.1.5 - jinja2==3.1.2 + elementpath==4.4.0 + jinja2==3.1.4 markdown-it-py==3.0.0 - markupsafe==2.1.3 + markupsafe==2.1.5 mdurl==0.1.2 - pygments==2.17.1 - pytest==8.2.0 - rich==13.7.0 - xmlschema==2.5.0 + pygments==2.18.0 + python=3.9 + rich==13.7.1 + xmlschema==3.3.1 + +[options.extras_require] +dev = + pytest==8.1.0 + pytest-cov==5.0.0 + +[options.entry_points] +console_scripts = + pain001 = pain001.cli:main [aliases] test = pytest -[tool:pytest] -testpaths = tests +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + +[tool.black] +line-length = 79 +target-version = ['py39'] + +[tool.isort] +profile = "black" +line_length = 79 +multi_line_output = 3 +include_trailing_comma = true +force_grid_wrap = 0 +combine_as_imports = true +known_first_party = "pain001" +known_third_party = "xmlschema" + +[tool.pytest] +addopts = "--cov=pain001 --cov-report=term-missing --cov-report=xml --cov-report=html --cov-fail-under=100" +testpaths = "tests" [wheel] universal = 1 diff --git a/tests/test_load_db_data.py b/tests/test_load_db_data.py new file mode 100644 index 0000000..464026e --- /dev/null +++ b/tests/test_load_db_data.py @@ -0,0 +1,48 @@ +import os +import sqlite3 +import pytest +from pain001.db.load_db_data import sanitize_table_name, load_db_data + + +# Test sanitize_table_name function +def test_sanitize_table_name(): + assert sanitize_table_name("valid_table_name") == "valid_table_name" + assert sanitize_table_name("invalid table name") == "invalid_table_name" + assert sanitize_table_name("123invalidname") == "table_123invalidname" + assert sanitize_table_name("table!@#name") == "table___name" + + +# Test load_db_data function +def test_load_db_data(tmp_path): + # Create a temporary SQLite database + db_file = tmp_path / "test.db" + conn = sqlite3.connect(db_file) + cursor = conn.cursor() + + # Create a test table and insert data + cursor.execute( + "CREATE TABLE test_table (id INTEGER PRIMARY KEY, name TEXT)" + ) + cursor.execute("INSERT INTO test_table (name) VALUES ('Alice')") + cursor.execute("INSERT INTO test_table (name) VALUES ('Bob')") + conn.commit() + conn.close() + + # Test loading data from the table + data = load_db_data(db_file, "test_table") + assert len(data) == 2 + assert data[0]["name"] == "Alice" + assert data[1]["name"] == "Bob" + + # Test FileNotFoundError + with pytest.raises(FileNotFoundError): + load_db_data("non_existent.db", "test_table") + + # Test sqlite3.OperationalError for non-existent table + with pytest.raises(sqlite3.OperationalError): + load_db_data(db_file, "non_existent_table") + + +# If the script is executed directly, run the tests +if __name__ == "__main__": + pytest.main()