Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/unit/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import elasticsearch
import pretend
import pytest
import sqlalchemy

from pyramid.httpexceptions import (
HTTPBadRequest,
Expand Down Expand Up @@ -601,7 +602,13 @@ def test_health():
)

assert health(request) == "OK"
assert request.db.execute.calls == [pretend.call("SELECT 1")]
assert len(request.db.execute.calls) == 1
assert len(request.db.execute.calls[0].args) == 1
assert len(request.db.execute.calls[0].kwargs) == 0
assert isinstance(
request.db.execute.calls[0].args[0], sqlalchemy.sql.expression.TextClause
)
assert request.db.execute.calls[0].args[0].text == "SELECT 1"


class TestForceStatus:
Expand Down
4 changes: 2 additions & 2 deletions warehouse/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
view_config,
view_defaults,
)
from sqlalchemy import func
from sqlalchemy import func, text
from sqlalchemy.sql import exists, expression
from trove_classifiers import deprecated_classifiers, sorted_classifiers
from webob.multidict import MultiDict
Expand Down Expand Up @@ -502,7 +502,7 @@ def sidebar_sponsor_logo(request):
def health(request):
# This will ensure that we can access the database and run queries against
# it without doing anything that will take a lock or block other queries.
request.db.execute("SELECT 1")
request.db.execute(text("SELECT 1"))

# Nothing will actually check this, but it's a little nicer to have
# something to return besides an empty body.
Expand Down