I have code like below
engine = create_engine(URL(
host="host",
username="username",
password="password",
database="dbname",
drivername="drivername",
port="port"
))
conn = engine.connect()
table_obj = Table(
table_name,
metadata,
autoload=True,
autoload_with=engine)
def check_something(conn, table_obj, u_id):
stmt = select(*[c for c in table_obj.c])
result = conn.execute(stmt).fetchall()
return result
Here i need to test the check_something method without connecting to postgresql database using pytest. Had gone through links available in google but everyone connecting to DB.
any option available to test the method by mocking DB connection like we mock AWS connections(S3, etc..)