Skip to content

Commit

Permalink
pyramid: adapt tests after refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Varsha GS <varsha.gs@ibm.com>
  • Loading branch information
Varsha GS committed Sep 12, 2024
1 parent 8ab3210 commit 126e4ec
Show file tree
Hide file tree
Showing 4 changed files with 370 additions and 264 deletions.
6 changes: 3 additions & 3 deletions tests/apps/pyramid_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# (c) Copyright Instana Inc. 2020

import os
from .app import pyramid_server as server
from ..utils import launch_background_thread
from tests.apps.pyramid_app.app import pyramid_server as server
from tests.apps.utils import launch_background_thread

app_thread = None

if not os.environ.get('CASSANDRA_TEST'):
if not os.environ.get("CASSANDRA_TEST"):
app_thread = launch_background_thread(server.serve_forever, "Pyramid")
44 changes: 26 additions & 18 deletions tests/apps/pyramid_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,50 @@
from pyramid.response import Response
import pyramid.httpexceptions as exc

from ...helpers import testenv
from tests.helpers import testenv

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

testenv["pyramid_port"] = 10815
testenv["pyramid_server"] = ("http://127.0.0.1:" + str(testenv["pyramid_port"]))
testenv["pyramid_server"] = "http://127.0.0.1:" + str(testenv["pyramid_port"])


def hello_world(request):
return Response('Ok')
return Response("Ok")


def please_fail(request):
raise exc.HTTPInternalServerError("internal error")


def tableflip(request):
raise BaseException("fake exception")


def response_headers(request):
headers = {
'X-Capture-This': 'Ok',
'X-Capture-That': 'Ok too'
}
headers = {"X-Capture-This": "Ok", "X-Capture-That": "Ok too"}
return Response("Stan wuz here with headers!", headers=headers)


def hello_user(request):
user = request.matchdict["user"]
return Response(f"Hello {user}!")


app = None
with Configurator() as config:
config.add_tween('instana.instrumentation.pyramid.tweens.InstanaTweenFactory')
config.add_route('hello', '/')
config.add_view(hello_world, route_name='hello')
config.add_route('fail', '/500')
config.add_view(please_fail, route_name='fail')
config.add_route('crash', '/exception')
config.add_view(tableflip, route_name='crash')
config.add_route('response_headers', '/response_headers')
config.add_view(response_headers, route_name='response_headers')
config.include("instana.instrumentation.pyramid.tweens")
config.add_route("hello", "/")
config.add_view(hello_world, route_name="hello")
config.add_route("fail", "/500")
config.add_view(please_fail, route_name="fail")
config.add_route("crash", "/exception")
config.add_view(tableflip, route_name="crash")
config.add_route("response_headers", "/response_headers")
config.add_view(response_headers, route_name="response_headers")
config.add_route("hello_user", "/hello_user/{user}")
config.add_view(hello_user, route_name="hello_user")
app = config.make_wsgi_app()

pyramid_server = make_server('127.0.0.1', testenv["pyramid_port"], app)

pyramid_server = make_server("127.0.0.1", testenv["pyramid_port"], app)
6 changes: 0 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
collect_ignore_glob.append("*frameworks/test_celery*")
collect_ignore_glob.append("*frameworks/test_gevent*")
collect_ignore_glob.append("*frameworks/test_grpcio*")
collect_ignore_glob.append("*frameworks/test_pyramid*")
collect_ignore_glob.append("*frameworks/test_sanic*")
collect_ignore_glob.append("*frameworks/test_tornado*")

Expand Down Expand Up @@ -90,11 +89,6 @@
collect_ignore_glob.append("*test_pep0249*")
collect_ignore_glob.append("*test_sqlalchemy*")

# Currently the latest version of pyramid depends on the `cgi` module
# which has been deprecated since Python 3.11 and finally removed in 3.13
# `ModuleNotFoundError: No module named 'cgi'`
collect_ignore_glob.append("*test_pyramid*")

# Currently not installable dependencies because of 3.13 incompatibilities
collect_ignore_glob.append("*test_fastapi*")
collect_ignore_glob.append("*test_google-cloud-pubsub*")
Expand Down
Loading

0 comments on commit 126e4ec

Please sign in to comment.