How to write unit test for below:
def processDbOutput(dbConfigObject, tuple):
dbConn = DBConnectionProvider(dbConfigObject.dbServer)
res=dbConn.excecute(......)
Want to write unit test for processDbOutput method accepting parameters.
And also mock the dbConn inside the method.
(update) The processDbOutput method is target method for multiprocessing. So it is good practice to create and close db connection within the same method. (Correct me if I am wrong).
Thanks in advance.
DBConnectionProvider(and thusdbConn), you can test the parametersexecuteis called with. Other than that, it is diffcult to guess what you want to do. Best you show us your test code (even if it is not working) to better describe your problem.mock.patch), but I want to know what do you want to test. E.g. can you write an example test with some assertions to show what you are going to test inprocessDbOutput?