Posts by Eduardo Matos • 146 points
4 posts
-
1
votes1
answer32
viewsA: Python: How to apply mock in dataclass?
This is because the class body is executed at the time of file interpretation, and you mock after that has happened (too late). My suggestion is to make the mock directly from your dataclass: with…
-
0
votes1
answer420
viewsA: How to test connection to Mysql database (sqlalchemy)
Connection to the database is usually not a business you test in your unit tests. The Sqlalchemy library certainly has a test for it. You would test, for example, whether a given function returns…
-
1
votes1
answer173
viewsA: How to Refactor Legacy JS to Implement Unit Tests?
You need four things to improve your code: A goal of how I would like your code to have organized (if you started from scratch, as you would do?) Every new code you create must obey its ideal…
-
1
votes1
answer276
viewsA: Ensure that the unit test is validated in an IF. Unit Test
Usually automated tests (unit/integration) go to the "edge" of your system, and in your example the "edge" of the system is the HTTP request. We limit our tests to the edge because it makes them…