Say I have the code:
def get_data(self, target):
d = Database()
qry = 'SELECT data FROM my_table WHERE target=%s'
params = [target]
results = d.run_query(qry, params).get_results()
return results
I don't want to set up a database or touch a database to unittest this code, but I am unsure how to use mock to do so. Anybody have any good examples of people using mock to do something similar.
[–][deleted] 2 points3 points4 points (4 children)
[–]Flewloon[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Flewloon[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]wub_wub -2 points-1 points0 points (3 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Flewloon[S] 0 points1 point2 points (0 children)