-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(pain001): ⬆️ upgrading dependencies and sync
- Loading branch information
1 parent
817628f
commit 772ab1a
Showing
5 changed files
with
185 additions
and
64 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,29 +15,63 @@ | |
# limitations under the License. | ||
|
||
[metadata] | ||
author = "Sebastien Rousseau <[email protected]>" | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |