I'm trying to write test functions for a project I'm working on. I using oracle as my database in the project and in the testing I'm using the in memory sqlite3 my problem is that some queries syntax are different. This isn't a problem when I'm unit testing because I can pass queries as parameters and adapt them but when I try to test the do() function responsible for calling all the functions this becomes undoable.
Here an example of my class:
def my_class:
def get_insert_query(self):
return "insert .... where my_date > sysdate"
def insert(self,query):
...
def get_update_query(self):
return "update .... where my_date > sysdate"
def update(self,query):
...
def do(self):
query = self.get_insert_query()
self.insert(query)
query = self.get_update_query()
self.update()
I want to test do() function. I found out that's it possible to replace a function using the patch from unittest.mock to replace get_insert_query with a function that return a query adapted to sqlite3 but my problem with it that it doesn't the same order of execution and doesn't enable me to execute the rest of the function.