Skip to content

Commit

Permalink
Merge pull request #6 from cuenca-mx/update
Browse files Browse the repository at this point in the history
Update library
  • Loading branch information
Ricardo authored Jan 16, 2021
2 parents 7b7b75c + 6f98be3 commit 8942ca2
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 45 deletions.
64 changes: 41 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,57 @@ SHELL := bash
PATH := ./venv/bin:${PATH}
PYTHON=python3.7
PROJECT=cep
isort = isort -rc -ac $(PROJECT) tests setup.py
isort = isort $(PROJECT) tests setup.py
black = black -S -l 79 --target-version py37 $(PROJECT) tests setup.py

all: test
.PHONY: all
all: testt

venv:
$(PYTHON) -m venv --prompt $(PROJECT) venv
pip install -qU pip
$(PYTHON) -m venv --prompt $(PROJECT) venv
pip install -qU pip

install-test:
pip install -q .[test]
.PHONY: install
install:
pip install -qU -r requirements.txt

.PHONY: install-test
install-test: install
pip install -qU -r requirements-test.txt

.PHONY: test
test: clean install-test lint
python setup.py test
pytest

.PHONY: format
format:
$(isort)
$(black)
$(isort)
$(black)

.PHONY: lint
lint:
$(isort) --check-only
$(black) --check
flake8 $(PROJECT) tests setup.py
$(isort) --check-only
$(black) --check
flake8 $(PROJECT) tests setup.py
mypy $(PROJECT) tests

.PHONY: clean
clean:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
rm -rf build dist $(PROJECT).egg-info

release: clean
python setup.py sdist bdist_wheel
twine upload dist/*


.PHONY: all install-test release test clean-pyc
rm -rf `find . -name __pycache__`
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
rm -rf .cache
rm -rf .pytest_cache
rm -rf .mypy_cache
rm -rf htmlcov
rm -rf *.egg-info
rm -f .coverage
rm -f .coverage.*
rm -rf build
rm -rf dist

.PHONY: release
release: test clean
python setup.py sdist bdist_wheel
twine upload dist/*
3 changes: 2 additions & 1 deletion cep/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
__all__ = ['Cuenta', 'Client', 'Transferencia']
__all__ = ['__version__', 'Cuenta', 'Client', 'Transferencia']

from .client import Client
from .cuenta import Cuenta
from .transferencia import Transferencia
from .version import __version__
Empty file added cep/py.typed
Empty file.
7 changes: 3 additions & 4 deletions cep/transferencia.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def validar(
receptor=receptor,
sello=resp.get('sello'),
)
transferencia.__client = client
setattr(transferencia, '__client', client)
return transferencia

def descargar(self, formato: str = 'PDF') -> bytes:
Expand Down Expand Up @@ -97,9 +97,8 @@ def _validar(
monto=monto,
)
resp = client.post('/valida.do', request_body)
if b'no encontrada' in resp:
client = None # No pudó validar
return client
# None si no pudó validar
return client if b'no encontrada' not in resp else None

@staticmethod
def _descargar(client: Client, formato: str = 'PDF') -> bytes:
Expand Down
1 change: 1 addition & 0 deletions cep/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.1.4'
7 changes: 7 additions & 0 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pytest==5.4.3
pytest-vcr==1.0.2
pytest-cov==2.10.0
black==19.10b0
flake8==3.8.3
isort[pipfile]==4.3.21
mypy==0.790
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
requests==2.24.0
clabe==1.2.0
lxml==4.5.1
dataclasses>=0.6;python_version<"3.7"
25 changes: 25 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,28 @@ test=pytest

[tool:pytest]
addopts = -p no:warnings -v --cov-report term-missing --cov=cep

[flake8]
inline-quotes = '
multiline-quotes = """
[isort]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
[mypy-lxml]
ignore_missing_imports = true
[mypy-clabe]
ignore_missing_imports = true
[mypy-pytest]
ignore_missing_imports = true
[coverage:report]
precision = 2
exclude_lines =
pragma: no cover
if TYPE_CHECKING:
27 changes: 10 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import setuptools
from importlib.machinery import SourceFileLoader

from setuptools import find_packages, setup

version = SourceFileLoader('version', 'cep/version.py').load_module()

install_requirements = [
'requests==2.24.0',
Expand All @@ -7,36 +11,25 @@
'dataclasses>=0.6;python_version<"3.7"',
]

test_requires = (
[
'pytest==5.4.3',
'pytest-vcr==1.0.2',
'pytest-cov==2.10.0',
'black==19.10b0',
'flake8==3.8.3',
'isort[pipfile]==4.3.21',
],
)

with open('README.md', 'r') as f:
long_description = f.read()


setuptools.setup(
setup(
name='cepmex',
version='0.1.3',
version=version.__version__,
author='Cuenca',
author_email='[email protected]',
description='CEP client library',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/cuenca-mx/cep-python',
packages=setuptools.find_packages(),
packages=find_packages(),
include_package_data=True,
package_data=dict(cep=['py.typed']),
python_requires='>=3.7',
install_requires=install_requirements,
setup_requires=['pytest-runner'],
tests_require=test_requires,
extras_require=dict(test=test_requires),
classifiers=[
'Programming Language :: Python :: 3.7',
'License :: OSI Approved :: MIT License',
Expand Down

0 comments on commit 8942ca2

Please sign in to comment.