forked from PyAr/pyafipws
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add PyQR COM server integration and testing
- Add PyQR component registration step in Windows installer workflow - Create register_pyqr.py and register_pyqr.bat for COM server registration - Update pyqr.py to include parent directory in sys.path - Add new test_pyqr.ps1 for testing PyQR functionality Signed-off-by: SONIABHISHEK121 <[email protected]>
- Loading branch information
1 parent
9901a35
commit 9662e78
Showing
5 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
python C:\Users\ADMIN\Desktop\pyafipws\register_pyqr.py | ||
pause |
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,11 @@ | ||
import sys | ||
import os | ||
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) | ||
os.environ['PYTHONPATH'] = os.path.abspath(os.path.dirname(__file__)) | ||
import win32com.server.register | ||
import pyqr | ||
|
||
win32com.server.register.UseCommandLine(pyqr.PyQR) | ||
|
||
|
||
|
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,69 @@ | ||
# # Test script for PyQR COM object | ||
|
||
# # Create PyQR COM object | ||
# $PyQR = New-Object -ComObject PyQR | ||
|
||
# Describe "PyQR Tests" { | ||
# It "Can create a file" { | ||
# $archivo = $PyQR.CrearArchivo() | ||
# $archivo | Should -Not -BeNullOrEmpty | ||
# } | ||
|
||
# It "Can generate QR image" { | ||
# $ver = 1 | ||
# $fecha = "2020-10-13" | ||
# $cuit = 30000000007 | ||
# $pto_vta = 10 | ||
# $tipo_cmp = 1 | ||
# $nro_cmp = 94 | ||
# $importe = 12100 | ||
# $moneda = "DOL" | ||
# $ctz = 65 | ||
# $tipo_doc_rec = 80 | ||
# $nro_doc_rec = 20000000001 | ||
# $tipo_cod_aut = "E" | ||
# $cod_aut = 70417054367476 | ||
|
||
# $url = $PyQR.GenerarImagen($ver, $fecha, $cuit, $pto_vta, $tipo_cmp, $nro_cmp, | ||
# $importe, $moneda, $ctz, $tipo_doc_rec, $nro_doc_rec, | ||
# $tipo_cod_aut, $cod_aut) | ||
# $url | Should -Not -BeNullOrEmpty | ||
# Test-Path $url | Should -Be $true | ||
# } | ||
# } | ||
|
||
$PyQR = New-Object -ComObject PyQR | ||
|
||
Describe "PyQR Tests" { | ||
It "Can create a file" { | ||
$archivo = $PyQR.CrearArchivo() | ||
$archivo | Should -Not -BeNullOrEmpty | ||
} | ||
|
||
It "Can generate QR image URL" { | ||
$ver = 1 | ||
$fecha = "2020-10-13" | ||
$cuit = 30000000007 | ||
$pto_vta = 10 | ||
$tipo_cmp = 1 | ||
$nro_cmp = 94 | ||
$importe = 12100 | ||
$moneda = "DOL" | ||
$ctz = 65 | ||
$tipo_doc_rec = 80 | ||
$nro_doc_rec = 20000000001 | ||
$tipo_cod_aut = "E" | ||
$cod_aut = 70417054367476 | ||
|
||
$url = $PyQR.GenerarImagen($ver, $fecha, $cuit, $pto_vta, $tipo_cmp, $nro_cmp, | ||
$importe, $moneda, $ctz, $tipo_doc_rec, $nro_doc_rec, | ||
$tipo_cod_aut, $cod_aut) | ||
$url | Should -Not -BeNullOrEmpty | ||
Write-Host "Generated QR image URL: $url" | ||
$url | Should -Match '^https://www\.afip\.gob\.ar/fe/qr/\?p=' | ||
|
||
# Optionally, check if the URL is accessible | ||
$response = Invoke-WebRequest -Uri $url -Method Head -UseBasicParsing | ||
$response.StatusCode | Should -Be 200 | ||
} | ||
} |