Skip to content

Commit

Permalink
Fix for sqlalchemy 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Jun 2, 2023
1 parent c2e18ae commit 3fa4a86
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion product_listings_manager/rest_api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get(self):
"""

try:
db.engine.execute("SELECT 1")
db.session.execute(db.text("SELECT 1"))
except SQLAlchemyError as e:
current_app.logger.warning("DB health check failed: %s", e)
return {"ok": False, "message": "DB Error: {}".format(e)}, 503
Expand Down
2 changes: 1 addition & 1 deletion tests/test_rest_api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_get_version(self, client):


class TestHealth(object):
@patch("product_listings_manager.rest_api_v1.db.engine.execute")
@patch("product_listings_manager.rest_api_v1.db.session.execute")
def test_health_db_fail(self, mock_db, client):
mock_db.side_effect = SQLAlchemyError("db connect error")
r = client.get("/api/v1.0/health")
Expand Down

0 comments on commit 3fa4a86

Please sign in to comment.