diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..375de91 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +.pytest_cache diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a2488fe --- /dev/null +++ b/LICENSE @@ -0,0 +1,2 @@ +All rights reserved by Piotr Przetacznik +MIT License diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b87be7f --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,8 @@ +recursive-include resources * +include templates/InitSession.xml +include templates/invoice_example.xml +include MANIFEST.in +include README.md +include LICENSE.txt +include requirements.txt +include pytest.ini diff --git a/README.md b/README.md index fb21f05..f905fdb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,12 @@ # KSEF utils +## Installing package from source + +```Bash +$ cd ksef-utils +$ pip install -e . +``` + ## Run tests ```Bash @@ -32,7 +39,8 @@ export KSEF_NIP="..." Run all e2e/functional/current tests ``` -$ pytest -svvv test_ksef.py -m "e2e and not ignore" -$ pytest -svvv test_ksef.py -m "functional and not ignore" -$ pytest -svvv test_ksef.py -m "current and not ignore" +$ pytest -svvv tests/test_ksef.py -m "e2e and not ignore" +$ pytest -svvv tests/test_ksef.py -m "functional and not ignore" +$ pytest -svvv tests/test_ksef.py -m "current and not ignore" +$ ./run_tests.sh ``` diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..d3827e7 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0 diff --git a/ksef_utils/__init__.py b/ksef_utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config.py b/ksef_utils/config.py similarity index 92% rename from config.py rename to ksef_utils/config.py index 5e5d852..402024d 100644 --- a/config.py +++ b/ksef_utils/config.py @@ -1,7 +1,7 @@ from os import getenv from os.path import join import pytz -from utils import readfile +from ksef_utils.utils import readfile class Config: diff --git a/server.py b/ksef_utils/server.py similarity index 99% rename from server.py rename to ksef_utils/server.py index eb25247..9bd715e 100644 --- a/server.py +++ b/ksef_utils/server.py @@ -4,7 +4,7 @@ import base64 import hashlib import requests -from utils import ( +from ksef_utils.utils import ( render_template, encrypt, iso_to_milliseconds, diff --git a/utils.py b/ksef_utils/utils.py similarity index 100% rename from utils.py rename to ksef_utils/utils.py diff --git a/requirements.txt b/requirements.txt index 301314e..a4e1f07 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ requests pytest +pytest-cov Jinja2 pycryptodome lxml diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..333947b --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -xe + +# export TESTS_MARKERS="e2e and not ignore" +# export TESTS_MARKERS="functional and not ignore" +export TESTS_MARKERS="current and not ignore" + +python \ + -m pytest \ + tests \ + -m "$TESTS_MARKERS" \ + --cov-report term \ + --cov=ksef_utils \ + -svvv diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..6532c09 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,25 @@ +[metadata] +name = ksef-utils +version = file:VERSION +author = Piotr Przetacznik +author_email = "piotr.przetacznik+ksef@gmail.com", +long_description = file:README.md +url = https://github.com/pprzetacznik/ksef-utils +keywords = + invoices + ksef +classifiers = + Development Status :: 5 - Production/Stable + Environment :: Console + Intended Audience :: Developers + Intended Audience :: System Administrators + Intended Audience :: Financial and Insurance Industry + Intended Audience :: End Users/Desktop + Intended Audience :: Customer Service + License :: Other/Proprietary License + Programming Language :: Python :: 3.11 +license_files = + LICENSE + +[bdist_wheel] +universal = 0 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..27e262c --- /dev/null +++ b/setup.py @@ -0,0 +1,14 @@ +from os.path import join, dirname +from setuptools import setup, find_packages + + +def read(fname): + with open(join(dirname(__file__), fname)) as f: + return f.read() + + +setup( + packages=find_packages(), + package_data={"": ["*.txt"]}, + install_requires=read("requirements.txt").splitlines(), +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/conftest.py b/tests/conftest.py similarity index 87% rename from conftest.py rename to tests/conftest.py index 1a7cc3b..a5de80e 100644 --- a/conftest.py +++ b/tests/conftest.py @@ -1,8 +1,8 @@ import logging from os import getenv from pytest import fixture -from server import KSEFServer, KSEFService -from config import TestConfig, DemoConfig, ProdConfig +from ksef_utils.server import KSEFServer, KSEFService +from ksef_utils.config import TestConfig, DemoConfig, ProdConfig @fixture diff --git a/test_ksef.py b/tests/test_ksef.py similarity index 98% rename from test_ksef.py rename to tests/test_ksef.py index a95bfac..9a09e45 100644 --- a/test_ksef.py +++ b/tests/test_ksef.py @@ -1,8 +1,7 @@ from datetime import datetime -from time import sleep from json import dumps from pytest import mark, fixture -from utils import format_xml +from ksef_utils.utils import format_xml @mark.current