Skip to content

Commit

Permalink
add PyQR COM server integration and testing
Browse files Browse the repository at this point in the history
- 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
ABHISHEKSONI121 committed Aug 5, 2024
1 parent 9901a35 commit 9662e78
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/windows-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ jobs:
run: |
Import-Module Pester
Invoke-Pester .\tests\powershell\test_pyi25.ps1
- name: Register PyQR component
run: |
python register_pyqr.py
Get-Content -Path $Env:APPDATA\pyqr.log -ErrorAction SilentlyContinue
- name: Test PyQR COM server automation
run: |
Import-Module Pester
Invoke-Pester .\tests\powershell\test_pyqr.ps1
- name: Test WSAA command line interface
run: |
.\wsaa.exe --analizar reingart.crt reingart.key wsmtxca 300
Expand Down
1 change: 1 addition & 0 deletions pyqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import sys
import tempfile
import traceback
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

import qrcode

Expand Down
3 changes: 3 additions & 0 deletions register_pyqr.bat
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
11 changes: 11 additions & 0 deletions register_pyqr.py
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)



69 changes: 69 additions & 0 deletions tests/powershell/test_pyqr.ps1
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
}
}

0 comments on commit 9662e78

Please sign in to comment.