Skip to content

Commit 35294c2

Browse files
committed
Se ha añadido documentación nueva. Se reestructuró la carpeta tests. Se añadió scrutinizer, ci y docs. Se añadieron nuevos servicios. Se modificaron algunos servicios existentes. Se modificó el readme.
1 parent f663bca commit 35294c2

37 files changed

+1518
-195
lines changed

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master # Ejecuta pruebas al hacer push en la rama 'master'
7+
8+
env:
9+
env_var: ${{ vars.ENV_CONTEXT_VAR }}
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
python-version: ['3.11'] # Puedes cambiar las versiones según necesites
18+
19+
steps:
20+
- name: Check out repository code
21+
uses: actions/checkout@v3
22+
23+
- name: Setup Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: ${{ matrix.python-version }} # Configura la versión de Python desde la matriz
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
pip install -r requirements.txt
32+
33+
- name: Run Python tests
34+
env:
35+
BHEXPRESS_API_TOKEN: ${{ secrets.BHEXPRESS_API_TOKEN }}
36+
BHEXPRESS_EMISOR_RUT: ${{ vars.BHEXPRESS_EMISOR_RUT }}
37+
run: |
38+
make tests-readonly
39+
40+
- name: Upload pytest result report
41+
if: failure()
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: tests-results-python_${{ matrix.python-version }}.xml
45+
path: var/tests-results.xml
46+
47+
- name: Upload Coverage Report
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: tests-coverage-python_${{ matrix.python-version }}.xml
51+
path: var/tests-coverage.xml
52+
53+
- name: Display Python version
54+
run: python --version

.github/workflows/docs.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Docs
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
docs:
11+
name: Docs
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.11'
22+
23+
- name: Install Sphinx and dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install sphinx sphinx-rtd-theme
27+
28+
- name: Build Documentation
29+
run: |
30+
sphinx-build -b html docs/ build/docs
31+
32+
- name: Create CNAME file
33+
run: echo "api-client-python.docs.bhexpress.cl" > build/docs/CNAME
34+
35+
- name: Deploy to GitHub Pages
36+
if: success()
37+
uses: peaceiris/actions-gh-pages@v4
38+
with:
39+
github_token: ${{ secrets.GITHUB_TOKEN }}
40+
publish_dir: ./build/docs
41+
publish_branch: gh-pages

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ tests/*.json
2323
tests/*.csv
2424
tests/*.pdf
2525
tests/*.html
26+
tests/archivos/bhe_emitidas_pdf/*

.scrutinizer.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
checks:
2+
python: true
3+
4+
build:
5+
nodes:
6+
analysis:
7+
tests:
8+
override:
9+
- python-scrutinizer-run
10+
- command: make tests-readonly
11+
coverage:
12+
file: var/tests-coverage.xml
13+
format: clover
14+
environment:
15+
python:
16+
version: 3.11.10
17+
dependencies:
18+
before:
19+
- pip install -r requirements.txt
20+
21+
filter:
22+
paths:
23+
- libredte/*
24+
excluded_paths:
25+
- resources/*
26+
- tests/*
27+
- tools/*
28+
- var/*
29+
- vendor/*

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ install-dev:
1212
tests: install-dev
1313
python tests/run.py
1414

15+
tests-readonly:
16+
python3 tests/run.py bhe.boletas.test_listar_bhes
17+
python3 tests/run.py bhe.boletas.test_calcular_monto_bruto
18+
python3 tests/run.py bhe.boletas.test_calcular_monto_liquido
19+
python3 tests/run.py bhe.receptores.test_listar_receptores
20+
python3 tests/run.py bhe.servicios.test_listar_servicios
21+
1522
docs:
1623
sphinx-apidoc -o docs bhexpress && sphinx-build -b html docs docs/_build/html
1724

README.rst

Lines changed: 5 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -7,120 +7,16 @@ BHExpress: Cliente de API en Python
77
:target: https://pypi.org/project/bhexpress
88
.. image:: https://img.shields.io/pypi/pyversions/bhexpress.svg
99
:target: https://pypi.org/project/bhexpress
10+
.. image:: https://scrutinizer-ci.com/g/bhexpress/bhexpress-api-client-python/badges/quality-score.png?b=master
11+
:target: https://scrutinizer-ci.com/g/bhexpress/bhexpress-api-client-python/
12+
.. image:: https://scrutinizer-ci.com/g/bhexpress/bhexpress-api-client-python/badges/coverage.png?b=master
13+
:target: https://scrutinizer-ci.com/g/bhexpress/bhexpress-api-client-python/
1014
.. image:: https://img.shields.io/pypi/l/bhexpress.svg
1115
:target: https://raw.githubusercontent.com/bhexpress/bhexpress-api-client-python/master/COPYING
1216

1317
Cliente para realizar la integración con los servicios web de `BHExpress <https://www.bhexpress.cl>`_ desde Python.
1418

15-
Instalación y actualización
16-
---------------------------
17-
18-
Instalar usando un entorno virtual y PIP con:
19-
20-
.. code:: shell
21-
22-
python3 -m venv venv
23-
source venv/bin/activate
24-
pip install bhexpress
25-
26-
Actualizar usando PIP con:
27-
28-
.. code:: shell
29-
30-
pip install bhexpress --upgrade
31-
32-
Modo de uso
33-
-----------
34-
35-
Se recomienda ver los ejemplos para más detalles. Lo que se muestra aquí es sólo
36-
una idea, y muy resumida:
37-
38-
Lo más simple, y recomendado, es usar una variable de entorno con el
39-
`token del usuario <https://bhexpress.cl/usuarios/perfil#token>`_,
40-
el cual será reconocida automáticamente por el cliente:
41-
42-
.. code:: python
43-
44-
from bhexpress.api_client.bhe.boletas import Boleta
45-
46-
client = Boleta()
47-
48-
boletas = client.listar()
49-
print(boletas)
50-
51-
Lo que hizo el ejemplo anterior es listar boletas emitidas en un resultado e imprimir dicho resultado en consola.
52-
53-
Variables de entorno
54-
--------------------
55-
56-
La aplicación y las pruebas hacen uso de variables de entornos. Si quieres usar
57-
estos, debes tenerlas creadas. En Windows 10 se hace con:
58-
59-
.. code:: shell
60-
61-
set BHEXPRESS_API_URL="https://bhexpress.cl"
62-
set BHEXPRESS_API_TOKEN="" # aquí el token obtenido en https://bhexpress.cl/usuarios/perfil#token
63-
set BHEXPRESS_EMISOR_RUT="" # aquí el RUT del emisor de las BHE
64-
65-
Ejemplo de definición de variables de entorno en la consola de Linux:
66-
67-
.. code:: shell
68-
69-
export BHEXPRESS_API_URL="https://bhexpress.cl"
70-
export BHEXPRESS_API_TOKEN="" # aquí el token obtenido en https://bhexpress.cl/usuarios/perfil#token
71-
export BHEXPRESS_EMISOR_RUT="" # aquí el RUT del emisor de las BHE
72-
73-
Pruebas
74-
-------
75-
76-
Las pruebas utilizan un archivo llamado `test.env`, que sirve para definir todas las variables de entorno
77-
necesarias para ejecutar estas pruebas. Las pruebas se crearon para probar los ejemplos vistos previamente
78-
en el capítulo `Ejemplos`.
79-
80-
Estas pruebas utilizan `unittest`, se ejecutan con el archivo `run.py`, y dependiendo de cómo se configure
81-
`test.env`, se pueden omitir ciertas pruebas. Asegúrate de definir `BHEXPRESS_API_URL`, `BHEXPRESS_API_TOKEN`
82-
y `BHEXPRESS_EMISOR_RUT` en `test.env`, o no podrás efectuar las pruebas.
83-
84-
Para ejecutar las pruebas unitarias, debes ejecutar el siguiente código en consola desde la raíz del proyecto:
85-
86-
.. code:: shell
87-
88-
python tests/run.py
89-
90-
Si quieres ejecutar una prueba específica, deberás especificar el nombre y ruta:
91-
92-
.. code:: shell
93-
94-
python tests/run.py boletas.test_boletas.TestBheBoletas.test1_listar
95-
96-
Para ejecutar otros ejemplos, debes reemplazar `test1_listar` por el nombre de alguna de las otras pruebas descritas posteriormente.
97-
98-
A continuación se pondrán instrucciones de cómo probar el cliente de API de Python:
99-
100-
* `test1_listar()`:
101-
- Prueba que permite obtener un listado de todas las boletas emitidas a través de BHExpress usando algunos filtros.
102-
- Variables necesarias: `TEST_LISTAR_PERIODO`, `TEST_LISTAR_CODIGORECEPTOR`
103-
- Variable de ejecución: `Ninguna`
104-
* `test2_emitir()`:
105-
- Prueba que permite emitir una BHE a un receptor.
106-
- Variables necesarias: `TEST_EMITIR_FECHA_EMIS`, `TEST_EMITIR_EMISOR`, `TEST_EMITIR_RECEPTOR`, `TEST_EMITIR_RZNSOC_REC`, `TEST_EMITIR_DIR_REC`, `TEST_EMITIR_COM_REC`
107-
- Variable de ejecución: `TEST_EMITIR_EMISOR`
108-
* `test3_pdf()`:
109-
- Prueba que permite obtener una BHE y convertirla a un PDF.
110-
- Variables necesarias: `Ninguna`
111-
- Variable de ejecución: `TEST_PDF_PROBAR`
112-
* `test4_email()`:
113-
- Prueba que permite enviar un email a un destinatario con una BHE específica.
114-
- Variables necesarias: `TEST_EMAIL_NUMEROBHE`, `TEST_EMAIL_CORREO`
115-
- Variable de ejecución: `TEST_EMAIL_NUMEROBHE` y `TEST_EMAIL_CORREO`
116-
* `test5_anular()`:
117-
- Prueba que permite anular una BHE existente.
118-
- Variables necesarias: `Ninguna`
119-
- Variables de ejecución: `TEST_ANULAR_PROBAR`
120-
121-
Las `variables necesarias` son aquellas variables que se necesitan para ejecutar las pruebas.
122-
Las `variables de ejecución` son aquellas variables que permitirán ejecutar u omitir las pruebas a las que pertenecen.
123-
Si las variables de ejecución tienen un valor específico o son texto en blanco, entonces la prueba será omitida, pero no fallida.
19+
Revisa la `documentación <https://api-client-python.docs.bhexpress.cl/guide/index.html>`_ de la biblioteca para más información, sus características y detalles de su uso.
12420

12521
Licencia
12622
--------

0 commit comments

Comments
 (0)