Skip to content

Commit

Permalink
feat(windows-installer): update build process and add PyI25 COM serve…
Browse files Browse the repository at this point in the history
…r tests

- Update py2exe version to 0.13.0.2 in requirements-dev.txt
- Simplify version handling in setup_win.py
- Add PowerShell test script for PyI25 COM server automation
- Implement Pester testing framework for PyI25 in CI workflow
- Add step to list dist folder contents in CI workflow

Signed-off-by: SONIABHISHEK121 <[email protected]>
  • Loading branch information
ABHISHEKSONI121 committed Aug 5, 2024
1 parent 90ef00f commit 9901a35
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 42 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/windows-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ jobs:
- name: Build executables
run: |
python setup_win.py py2exe
- name: List dist folder contents
run: |
dir .\dist
- name: Download Visual Studio Redistributable (32bits)
if: matrix.targetplatform == 'x86'
run: |
Expand Down Expand Up @@ -123,6 +126,14 @@ jobs:
- name: Copy rece.ini file
run: |
copy conf\rece.ini .
- name: Install Pester
shell: powershell
run: |
Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser
- name: Test PyI25 COM server automation
run: |
Import-Module Pester
Invoke-Pester .\tests\powershell\test_pyi25.ps1
- name: Test WSAA command line interface
run: |
.\wsaa.exe --analizar reingart.crt reingart.key wsmtxca 300
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ pytest-freezegun==0.4.2; python_version > '3'
pytest-mock==2.0.0; python_version <= '2.7'
pytest-mock==3.10.0; python_version > '2.7'
pywin32==304; sys_platform == "win32" and python_version > '3'
py2exe==0.11.1.1; sys_platform == "win32" and python_version > '3'
py2exe==0.13.0.2; sys_platform == "win32" and python_version > '3'
75 changes: 34 additions & 41 deletions setup_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
import warnings
import sys

try:
rev = subprocess.check_output(['git', 'rev-list', '--count', '--all'],
stderr=subprocess.PIPE).strip().decode("ascii")
except:
rev = 0

__version__ = "%s.%s.%s" % (sys.version_info[0:2] + (rev, ))
__version__ = "3.10.3028"

HOMO = True

Expand Down Expand Up @@ -186,7 +180,7 @@

# add 32bit or 64bit tag to the installer name
import platform
__version__ += "-" + platform.architecture()[0]



# new webservices:
Expand All @@ -196,7 +190,6 @@
if wsaa.TYPELIB:
data_files.append(("typelib", ["typelib/wsaa.tlb"]))

__version__ += "+wsaa_" + wsaa.__version__
HOMO &= wsaa.HOMO

if 'wsfev1' in globals():
Expand All @@ -208,7 +201,7 @@
]
if wsfev1.TYPELIB:
data_files.append(("typelib", ["typelib/wsfev1.tlb"]))
__version__ += "+wsfev1_" + wsfev1.__version__

HOMO &= wsfev1.HOMO

if 'wsfexv1' in globals():
Expand All @@ -219,7 +212,7 @@
Target(module=wsfexv1, script='wsfexv1.py', dest_base="wsfexv1_cli"),
Target(module=recex1, script='recex1.py'),
]
__version__ += "+wsfexv1_" + wsfexv1.__version__

HOMO &= wsfexv1.HOMO

if 'wsbfev1' in globals():
Expand All @@ -230,7 +223,7 @@
Target(module=wsbfev1, script='wsbfev1.py', dest_base="wsbfev1_cli"),
Target(module=receb1, script='receb1.py'),
]
__version__ += "+wsbfev1_" + wsbfev1.__version__

HOMO &= wsbfev1.HOMO

if 'wsmtx' in globals():
Expand All @@ -241,7 +234,7 @@
Target(module=wsmtx, script='wsmtx.py', dest_base="wsmtx_cli"),
Target(module=recem, script='recem.py'),
]
__version__ += "+wsmtx_" + wsmtx.__version__

HOMO &= wsmtx.HOMO

if 'wsct' in globals():
Expand All @@ -252,7 +245,7 @@
Target(module=wsct, script='wsct.py', dest_base="wsct_cli"),
Target(module=recet, script='recet.py'),
]
__version__ += "+wsct_" + wsct.__version__

HOMO &= wsct.HOMO

if 'wsfecred' in globals():
Expand All @@ -264,7 +257,7 @@
]
data_files += [
]
__version__ += "+wsfecred_" + wsfecred.__version__

HOMO &= wsfecred.HOMO

if 'ws_sire' in globals():
Expand All @@ -276,7 +269,7 @@
]
data_files += [
]
__version__ += "+sire_" + ws_sire.__version__

HOMO &= ws_sire.HOMO

if 'pyfepdf' in globals():
Expand All @@ -295,7 +288,7 @@
"plantillas/factura.csv",
"plantillas/recibo.csv"]),
]
__version__ += "+pyfepdf_" + pyfepdf.__version__

HOMO &= pyfepdf.HOMO

if 'pyemail' in globals():
Expand All @@ -310,7 +303,7 @@
]
data_files += [
]
__version__ += "+pyemail_" + pyemail.__version__


if 'pyi25' in globals():
kwargs['com_server'] += [
Expand All @@ -324,7 +317,7 @@
]
data_files += [
]
__version__ += "+pyi25_" + pyi25.__version__


if 'pyqr' in globals():
kwargs['com_server'] += [
Expand All @@ -338,7 +331,7 @@
]
data_files += [
]
__version__ += "+pyqr_" + pyqr.__version__


if 'wsctg' in globals():
kwargs['com_server'] += [
Expand All @@ -347,7 +340,7 @@
kwargs['console'] += [
Target(module=wsctg, script='wsctg.py', dest_base="wsctg_cli"),
]
__version__ += "+wsctgv4_" + wsctg.__version__

HOMO &= wsctg.HOMO

if 'wslpg' in globals():
Expand All @@ -368,7 +361,7 @@
"plantillas/liquidacion_wslpg_ajuste_debcred.png",
]),
]
__version__ += "+wslpg_" + wslpg.__version__

HOMO &= wslpg.HOMO

if 'wsltv' in globals():
Expand All @@ -383,7 +376,7 @@
("plantillas", [
]),
]
__version__ += "+wsltv_" + wsltv.__version__

HOMO &= wsltv.HOMO

if 'wslum' in globals():
Expand All @@ -396,7 +389,7 @@
data_files += [
("conf", ["conf/wslum.ini"]),
]
__version__ += "+wslum_" + wslum.__version__

HOMO &= wslum.HOMO

if 'wslsp' in globals():
Expand All @@ -409,7 +402,7 @@
data_files += [
("conf", ["conf/wslsp.ini"]),
]
__version__ += "+wslsp_" + wslsp.__version__

HOMO &= wslsp.HOMO

if 'wsremcarne' in globals():
Expand All @@ -422,7 +415,7 @@
data_files += [
("conf", ["conf/wsremcarne.ini"]),
]
__version__ += "+wsremcarne_" + wsremcarne.__version__

HOMO &= wsremcarne.HOMO

if 'wsremharina' in globals():
Expand All @@ -435,7 +428,7 @@
data_files += [
("conf", ["conf/wsremharina.ini"]),
]
__version__ += "+wsremharina_" + wsremharina.__version__

HOMO &= wsremharina.HOMO

if 'wsremazucar' in globals():
Expand All @@ -448,7 +441,7 @@
data_files += [
("conf", ["conf/wsremazucar.ini"]),
]
__version__ += "+wsremazucar_" + wsremazucar.__version__

HOMO &= wsremazucar.HOMO

if 'wscoc' in globals():
Expand All @@ -458,7 +451,7 @@
kwargs['console'] += [
Target(module=wscoc, script='wscoc.py', dest_base="wscoc_cli"),
]
__version__ += "+wscoc_" + wscoc.__version__

HOMO &= wscoc.HOMO

if 'wscdc' in globals():
Expand All @@ -468,7 +461,7 @@
kwargs['console'] += [
Target(module=wscdc, script='wscdc.py', dest_base="wscdc_cli"),
]
__version__ += "+wscdc_" + wscdc.__version__

HOMO &= wscdc.HOMO

if 'ws_sr_padron' in globals():
Expand All @@ -478,7 +471,7 @@
kwargs['console'] += [
Target(module=ws_sr_padron, script='ws_sr_padron.py', dest_base="ws_sr_padron_cli"),
]
__version__ += "+ws_sr_padron_" + ws_sr_padron.__version__

HOMO &= ws_sr_padron.HOMO

if 'cot' in globals():
Expand All @@ -497,7 +490,7 @@
"datos/TB_20111111112_000000_20101229_000001.txt",
"datos/TB_20111111112_000000_20101229_000001.xml",
]), ("conf", ["conf/arba.crt"])]
__version__ += "+cot_" + cot.__version__

HOMO &= cot.HOMO

if 'iibb' in globals():
Expand All @@ -508,7 +501,7 @@
Target(module=iibb, script='iibb.py', dest_base="iibb_cli")
]
data_files += [("conf", ["conf/arba.crt"])]
__version__ += "+iibb_" + iibb.__version__

HOMO &= iibb.HOMO

if 'trazamed' in globals():
Expand All @@ -521,7 +514,7 @@
if trazamed.TYPELIB:
kwargs['windows'] += [Target(module=trazamed, script="trazamed.py", dest_base="trazamed")]
data_files.append((".", ["trazamed.tlb"]))
__version__ += "+trazamed_" + trazamed.__version__

HOMO &= trazamed.HOMO

if 'trazaprodmed' in globals():
Expand All @@ -531,7 +524,7 @@
kwargs['console'] += [
Target(module=trazaprodmed, script='trazaprodmed.py', dest_base="trazaprodmed_cli"),
]
__version__ += "+trazaprodmed_" + trazaprodmed.__version__

HOMO &= trazaprodmed.HOMO

if 'trazarenpre' in globals():
Expand All @@ -544,7 +537,7 @@
if trazarenpre.TYPELIB:
kwargs['windows'] += [Target(module=trazarenpre, script="trazarenpre.py", dest_base="trazarenpre")]
data_files.append((".", ["trazarenpre.tlb"]))
__version__ += "+trazarenpre_" + trazarenpre.__version__

HOMO &= trazarenpre.HOMO

if 'trazafito' in globals():
Expand All @@ -554,7 +547,7 @@
kwargs['console'] += [
Target(module=trazafito, script='trazafito.py', dest_base="trazafito_cli"),
]
__version__ += "+trazafito_" + trazafito.__version__

HOMO &= trazafito.HOMO

if 'trazavet' in globals():
Expand All @@ -564,7 +557,7 @@
kwargs['console'] += [
Target(module=trazavet, script='trazavet.py', dest_base="trazavet_cli"),
]
__version__ += "+trazavet_" + trazavet.__version__

HOMO &= trazavet.HOMO

if 'padron' in globals():
Expand All @@ -579,7 +572,7 @@
data_files += [(".", [
"padron.db",
])]
__version__ += "+padron_" + padron.__version__

#HOMO &= padron.HOMO

if 'sired' in globals():
Expand All @@ -589,7 +582,7 @@
kwargs['console'] += [
Target(module=sired, script='sired.py', dest_base="sired_cli"),
]
__version__ += "+sired_" + sired.__version__


# custom installer:
kwargs['cmdclass'] = {"py2exe": build_installer}
Expand All @@ -607,7 +600,7 @@
pass

# agrego tag de homologación (testing - modo evaluación):
__version__ += "-homo" if HOMO else "-full"


# agrego ejemplos
##if HOMO:
Expand Down
37 changes: 37 additions & 0 deletions tests/powershell/test_pyi25.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Test script for PyI25 COM object

# Create PyI25 COM object
$PyI25 = New-Object -ComObject PyI25

Describe "PyI25 Tests" {
# It "Version is not empty" {
# $PyI25.Version | Should -Not -BeNullOrEmpty
# }

It "Can generate barcode" {
$barras = "202675653930240016120303473904220110529"
$barras += $PyI25.DigitoVerificadorModulo10($barras)
$salida = Join-Path $PWD "barras_test.png"
$result = $PyI25.GenerarImagen($barras, $salida)
$result | Should -Be $true
Test-Path $salida | Should -Be $true
}

It "Digito Verificador calculation is correct" {
$barras = "202675653930240016120303473904220110529"
$digito = $PyI25.DigitoVerificadorModulo10($barras)
$digito | Should -Be "9"
}

It "Generated barcode file is valid" {
$salida = Join-Path $PWD "barras_test.png"
$fileInfo = Get-Item $salida
$fileInfo.Length | Should -BeGreaterThan 0
}

It "Can handle different input for DigitoVerificadorModulo10" {
$testInput = "123456789"
$digito = $PyI25.DigitoVerificadorModulo10($testInput)
$digito | Should -Not -BeNullOrEmpty
}
}

0 comments on commit 9901a35

Please sign in to comment.