I have this function defined:
def count_occurrences(cursor, cust_id):
cursor.execute("SELECT count(id) FROM users WHERE customer_id = %s", (cust_id))
total_count = cursor.fetchone()[0]
if total_count == 0:
return True
else:
return False
I want to unit test it, for that I need to mock the database call here.
How can this be done using pytest, mock?