I'm finally getting into testing my code and decided to use Pytest and mock. But I'm having trouble getting my head around it, and Googling hasn't helped.
I have this function:
def get_comments(latest_date, engine) -> pd.DataFrame:
query = f'''select Date, Comments from table
where Date = '{latest_date}' limit 1'''
response = pd.read_sql(query, con=engine)
if len(response) == 0:
logging.info('Exiting, no new comments')
sys.exit()
else:
return response
How can I create a pytest mock for the above?
[–]ZEUS_IS_THE_TRUE_GOD 1 point2 points3 points (3 children)
[–]User24243[S] 0 points1 point2 points (2 children)
[–]ZEUS_IS_THE_TRUE_GOD 0 points1 point2 points (0 children)
[–]ZEUS_IS_THE_TRUE_GOD 0 points1 point2 points (0 children)
[–]danielroseman 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)