Blog Post #8

Utkarsh
Published: 08/03/2021

In this blog I talk about my work done in the 8th week of my GSOC experience. This week my mentors had me working on 4 scripts, namely rece1.py, recem.py, recex1.py and receb1.py.

What did I do?

Testing and code coverage are two of the most important requirements of any project. Therefore much of my work lately can be seen focused around these two topics. Last week I had already written unit tests and increased the code coverage of 12 most important scripts. Each represented a web service and it was necessary that the code did not have unnecessary problems.

This week I worked on the above mentioned scripts and my work done for each of them can be found in the following links:-

What problems did I face ?

Most of my work this week comprised of finding minute errors that were causing failure of scripts. One the common errors in all 4 scripts was - 'entrada.txt not found error. All the 4 scripts required this file for working properly and it was generated with the help of /prueba command line option.

Another common error was in the function - depurar_xml(). This function was responsible for creating request.xml and response.xml files. Due to the difference in ways in which strings are handled in Python 2 and Python 3, this function required some modification in order to generate correct ouputs.
Similarly there were many instances where unicode errors were causing problems.

One other major problem that I faced was the presence of the sys.exit(0) statement that was present in all 4 scripts along with the command line options. Normally these statements seem harmless, but if pytest encounters them while testing, it leads to failure. Same goes with the input() function.
Example:-
        if "/dummy" in sys.argv:
            print("Consultando estado de servidores...")
            ws.Dummy()
            print("AppServerStatus", ws.AppServerStatus)
            print("DbServerStatus", ws.DbServerStatus)
            print("AuthServerStatus", ws.AuthServerStatus)
            sys.exit(0)

Writing a test for the /dummy command line option, would give an error when run.

Same goes with statements like these:-
        if "/consultarcaea" in sys.argv:
            periodo = input("Periodo: ")
            orden = input("Orden: ")

Here the error is due to the input() method, as pytest doesn't allow them. To make the above command line option work one has to read the command line arguments.
Something like this:-
            if len(sys.argv) > sys.argv.index("/consultarcaea") + 1:
                periodo = sys.argv[sys.argv.index("/consultarcaea") + 1]
                orden = sys.argv[sys.argv.index("/consultarcaea") + 2]
            else:
                periodo = input("Periodo (año-mes, ej 201108): ")
                orden = input("Orden (quincena, 1 u 2): ")


Overall I had fun while solving these problems. Watching little green dots appear after the pytest command offer an another level of satisfaction and content 😉.
DJDT

Versions

Time

Settings from gsoc.settings

Headers

Request

SQL queries from 1 connection

Static files (2312 found, 3 used)

Templates (11 rendered)

Cache calls from 1 backend

Signals

Log messages