Utkarsh's Blog

Weekly Check-In #8

Published: 08/01/2021

This check-in marks the beginning of the 8th week of my GSoC journey. This week is also going to be same in terms of the work done, as I will again be working on code coverage of 4 more scripts.

What will I be doing ?

This week I will be working on adding unit tests for 4 scripts and also increasing their coverage. The scripts are :-
  • rece1.py
  • recem.py
  • recex1.py
  • receb1.py

Did I get stuck anywhere till now?

Since I had already worked on the coverage of 12 scripts before, I did not face any major roadblock till now. But the entire week in in front of me and I am excited for the challenges.
View Blog Post

Blog Post #7

Published: 08/01/2021

In this blog I cover the work done by me in the 7th week of GSOC. This week had me working on code coverage. The initial target set by my mentors for code coverage was 85%. The following lines explain what I was able to achieve, what problems I faced and what still needs to be done.

What did I do?

As already mentioned above, I worked on increasing the code coverage for the package this week. I worked on a total of 12 scripts this week. In some of the scripts I was able to increase the coverage more that 80%, but in a few I was not able to due to some internal server errors. Overall I achieved 81% coverage.
My work on individual scripts can be seen in the following links:

Also the coverage for individual files can be seen below:-

pytest --cov-config=.coveragerc --cov=pyafipws tests/                   
=========================== test session starts ===========================
platform win32 -- Python 3.9.6, pytest-6.2.3, py-1.10.0, pluggy-0.13.1
rootdir: C:\Users\shiva\OneDrive - Birla Institute of Technology\Desktop\GSoC_online\pyafipws, configfile: pytest.ini
plugins: cov-2.12.1, freezegun-0.4.2, html-3.1.1, metadata-1.11.0, vcr-1.0.2
collected 360 items

tests\test_pyfepdf.py ..............                                                                                                                                             [  3%]
tests\test_ws_sr_padron.py s.sx                                                                                                                                                  [  5%]
tests\test_wsaa.py ..............                                                                                                                                                [  8%]
tests\test_wsbfev1.py ...............                                                                                                                                            [ 13%]
tests\test_wscdc.py s...........                                                                                                                                                 [ 16%]
tests\test_wsct.py ..........xx..xxxxxxxxxxssxxxxxx..                                                                                                                            [ 25%]
tests\test_wsfev1.py ..........................                                                                                                                                  [ 33%]
tests\test_wsfev1_dummy.py .                                                                                                                                                     [ 33%]
tests\test_wsfexv1.py .................                                                                                                                                          [ 38%]
tests\test_wslsp.py ......................................x....................                                                                                                  [ 54%]
tests\test_wsltv.py ............................x.................                                                                                                               [ 67%]
tests\test_wslum.py ........................x...........                                                                                                                         [ 77%]
tests\test_wsmtx.py ..........................................                                                                                                                   [ 88%]
tests\test_wsremcarne.py ........................................                                                                                                                [100%]

----------- coverage: platform win32, python 3.9.6-final-0 -----------
Name                                                                          Stmts   Miss  Cover
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\__init__.py         4      0   100%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\pyfepdf.py        802    162    80%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\wsaa.py           350     81    77%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\wsbfev1.py        382     53    86%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\wscdc.py          213     32    85%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\wsct.py           429    177    59%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\wsfev1.py         684     83    88%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\wsfexv1.py        454     73    84%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\wslsp.py          622    103    83%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\wsltv.py          561     84    85%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\wslum.py          461    111    76%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\wsmtx.py          607    119    80%
py3\Lib\site-packages\PyAfipWs-3.9.b_2522_-py3.9.egg\pyafipws\wsremcarne.py     432     66    85%
TOTAL                                                                          6001   1144    81%

======================= 333 passed, 5 skipped, 22 xfailed, 66 warnings in 57.58s =======================
View Blog Post

Weekly Check-In #7

Published: 07/29/2021

After 4 days of evaluation, I am back to working on the remainder of my proposal. This week's work is one of the most important aspect of my proposal, that is ,code coverage. My mentors have decided to keep the acceptable code coverage to 80% , but also told me that 85% is achievable.

What will I be doing?

. Code coverage is directly related to unit testing and determines what percentage of the code has been covered by the tests. Whenever a large application or service is designed, it is important to test that all the features are working properly before deploying. Therefore my work is to write more tests if required and fix bugs that will lead to the acceptable code coverage range. Currently, the overall code coverage is 46% and you can understand that I have a long week ahead of me. Also there are going to be many changes made and thus my mentors have asked me to make separate PRs for all the scripts. That means in total there would be about 12 PRs in this week alone.

Did I get stuck anywhere?

Yes, right of the bat I ran into some errors. Firstly the certificates required for authorization had expired. So they had to be replaced in order for me to continue. Secondly, some of the services were not linked with the new certificates. SO they too had to to linked by the mentors. Lastly, some of the command line options were not giving the expected output due to internal errors. I created issues for each of the above problems and informed my mentors for guidance. The issues can be seen here:- #70, #83, #84, #85.
View Blog Post

Blog Post #6

Published: 07/29/2021

This week marks the end of the first half of my GSoC experience and also the start of my first evaluation.

FIrst Evaluation....What has been done till now?

So, during the first 5 weeks my work comprised of the following :-
  • Merging the work from previous GSoC
  • Fixing errors that arose due to the merge
  • Fixing bugs due to Python versions
  • Adding pytest-vcr to the testing suite
  • Adding cassettes for later use
  • Adding more unit tests for the scripts
  • Adding Python entry Points
View Blog Post

Blog Post #5

Published: 07/14/2021

This blog covers the work done by me in the 5th week of GSoC. This week also marks the end of the first phase and with this work I will enter the first evaluation phase which is scheduled from 12th to 16th July. The work mentioned in this blog can be found in PR#69

What did I do?

As mentioned before my mentors had asked me to work on python entry points which basically allow us to call scripts directly from the command line using one word name. These entry points are installed when we install the package with the command python setup.py install. They allow an easy way to call scripts with their command line options with just one word instead of mentioning the whole whole module.

To do this I had to add a main() function to many scripts that contained all the command line options. This function would ultimately serve as the entry point of the scripts when called from the command line. While doing this I also had to keep in mind the variables that were modified inside this function because I would have to define a global declaration for them. This mainly constituted my work in the 5th week. The scripts for which I added entry points were:-
  • cot
  • iibb
  • padron
  • pyemail
  • pyfepdf
  • pyi25
  • pyqr
  • rece1
  • receb1
  • recem
  • recet
  • recex1
  • rg3685
  • sired
  • trazafito
  • trazamed
  • trazaprodmed
  • trazarenpre
  • trazavet
  • wdigdepfiel
  • ws_sire
  • ws_sr_padron
  • wsaa
  • wsbfev1
  • wscdc
  • wscoc
  • wsct
  • wsctg
  • wsfecred
  • wsfev1
  • wsfexv1
  • wslpg
  • wslsp
  • wsltv
  • wslum
  • wsmtx
  • wsremazucar
  • wsremcarne
  • wsremharina

I chose to add the entry points inside the setup.cfg file instead of setup.py file, because the configuration file was already present inside the package.

What problems did I face?

I think this was the only week that I can say that I did not face any significant problems. Since adding entry points was a straight-forward task, I only had to invest some time for this task. Although initially I did get stuck while finding the function that would serve as the entry point for the scripts. The problem was that not all scripts had a main() function in them, nor did the have a proper function that would serve as the entry point. Then with some tinkering and the help of my mentors I decided to add a main function in all the scripts. After this it was only a matter of adding them in the configuration file and making global declarations for the variables that were modified.


$ wsaa

para soporte de WebClient debe instalar httplib2
Encodign in cp1252
Usando CRT=reingart.crt KEY=reingart.key URL=https://wsaahomo.afip.gov.ar/ws/services/LoginCms SERVICE=wsfe TTL=36000
WSAA Version 3.11c  False

<loginticketresponse version="1.0">
<source>CN=wsaahomo, O=AFIP, C=AR, SERIALNUMBER=CUIT 33693450239 <destination>SERIALNUMBER=CUIT 20267565393, CN=reingart2019pub</destination> <uniqueid>657428365</uniqueid> <generationtime>2021-07-09T13:51:57.149-03:00</generationtime> <expirationtime>2021-07-10T01:51:57.149-03:00</expirationtime>
<credentials> <token>P+Cg==</token> <sign>s4M0=</sign> </credentials> </loginticketresponse> $ wsfev1 --prueba para soporte de WebClient debe instalar httplib2 Leyendo TA de C:\Users\pyafipws\py3test\lib\site-packages\pyafipws-3.9.b_2514_-py3.9.egg\pyafipws\cache\TA-2b4277f5962bd2cb0265c0fac4b32304.xml... b"FECAESolicitar(Auth=*{'Token': <class 'str'="">, 'Sign': <class 'str'="">, 'Cuit': <alias 'long'="" for="" '<class="" 'int'="">'>}*, FeCAEReq=*{'FeCabReq': *{'CantReg': <class 'int'="">, 'PtoVta': <class 'int'="">, 'CbteTipo': <class 'int'="">}*, 'FeDetReq': [*{'FECAEDetRequest': *{'Concepto': <class 'int'="">, 'DocTipo': <class 'sg':="" <class="" 'str'="">}*}*], 'Errors': [*{'Err': *{'Code': <class 'int'="">, 'Msg': <class 'str'="">}*}*]}*}**:\n\nSolicitud de C\xf3digo de Autorizaci\xf3n Electr\xf3nico (CAE)\nHeaders: None"</class></class></class></class></class></class></class></alias></class></class> Nro. Cbte. desde-hasta 493 493 Resultado A Reproceso CAE 71283954824423 Vencimiento 20210719 Observaciones 10217: El credito fiscal discriminado en el presente comprobante solo podra ser computado a efectos del Procedimiento permanente de transicion al Regimen General. 71283954824423 == 71283954824423 3 != 2 10217 != 10017 El credito fiscal discriminado en el presente comprobante solo podra ser computado a efectos del Procedimiento permanente de transicion al Regimen General. $ pyfepdf --prueba --mostrar para soporte de WebClient debe instalar httplib2 Encodign in cp1252 Prueba!
View Blog Post