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
19 changes: 19 additions & 0 deletions tests/integrations/django/myapp/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
ASGI entrypoint. Configures Django and then runs the application
defined in the ASGI_APPLICATION setting.
"""

import os
import django
from channels.routing import get_default_application

os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "tests.integrations.django.myapp.settings"
)

django.setup()

from sentry_asgi import SentryMiddleware

application = get_default_application()
application = SentryMiddleware(application)
12 changes: 12 additions & 0 deletions tests/integrations/django/myapp/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "tests.integrations.django.myapp.settings"
)

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
4 changes: 4 additions & 0 deletions tests/integrations/django/myapp/routing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from channels.http import AsgiHandler
from channels.routing import ProtocolTypeRouter

application = ProtocolTypeRouter({"http": AsgiHandler})
5 changes: 4 additions & 1 deletion tests/integrations/django/myapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def process_response(self, request, response):
}
]

WSGI_APPLICATION = "tests.django.myapp.wsgi.application"
WSGI_APPLICATION = "tests.integrations.django.myapp.wsgi.application"


# Database
Expand Down Expand Up @@ -150,3 +150,6 @@ def process_response(self, request, response):
# https://docs.djangoproject.com/en/2.0/howto/static-files/

STATIC_URL = "/static/"

# django-channels specific
ASGI_APPLICATION = "tests.integrations.django.myapp.routing.application"
1 change: 1 addition & 0 deletions tests/integrations/django/myapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
name="rest_framework_read_body_and_exc",
)
)
urlpatterns.append(path("rest-hello", views.rest_hello, name="rest_hello"))
except AttributeError:
pass

Expand Down
4 changes: 4 additions & 0 deletions tests/integrations/django/myapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def rest_framework_read_body_and_exc(request):
request.data
1 / 0

@api_view(["GET"])
def rest_hello(request):
return HttpResponse("ok")


except ImportError:
pass
Expand Down
4 changes: 3 additions & 1 deletion tests/integrations/django/myapp/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
os.environ.setdefault(
"DJANGO_SETTINGS_MODULE", "tests.integrations.django.myapp.settings"
)

application = get_wsgi_application()