I have a function that looks like this:
def finding_info(self):
query = """
SELECT u.name, u.id,
t.number_of_tasks,
FROM users u
INNER JOIN (
SELECT userId, COUNT(*) number_of_tasks
FROM tasks
WHERE status = "incomplete"
GROUP BY userId
) t ON u.id = t.userId
"""
self.cur.execute(query)
return self.cur.fetchall()
I am doing a simple join for 2 tables. How can I write unit tests for this?
What can I pass in and what kind out output can I check for? In short, what are the best test cases that I could use for unit testing in such a case?
I am using Pytest.
source https://stackoverflow.com/questions/71904763/unit-testing-for-sql-queries
Comments
Post a Comment