Skip to content

Commit

Permalink
upgraded channels to version 3 and fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shayanaijaz committed Oct 26, 2023
1 parent 7c46c48 commit 5ce7673
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 33 deletions.
53 changes: 36 additions & 17 deletions server/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server/portal/apps/notifications/consumers_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ async def auth_connect(user):

# Pass session ID in headers to authenticate.
communicator = WebsocketCommunicator(
NotificationsConsumer,
path='/ws/notifications/'
NotificationsConsumer.as_asgi(),
path='/ws/notifications/',
)
communicator.scope['user'] = user
connected, _ = await communicator.connect()
Expand Down
2 changes: 1 addition & 1 deletion server/portal/apps/notifications/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
from portal.apps.notifications.consumers import NotificationsConsumer

websocket_urlpatterns = [
re_path(r'ws/notifications/$', NotificationsConsumer),
re_path(r'ws/notifications/$', NotificationsConsumer.as_asgi()),
]
3 changes: 2 additions & 1 deletion server/portal/apps/webhooks/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.db import models
from django.conf import settings
from datetime import datetime
from django.utils import timezone


class ExternalCall(models.Model):
Expand All @@ -21,7 +22,7 @@ class ExternalCall(models.Model):
)

# Timestamp for outbound external call
time = models.DateTimeField(default=datetime.now)
time = models.DateTimeField(default=timezone.now)

# Callback class to be executed when a webhook is received
callback = models.CharField(max_length=300, null=True)
Expand Down
8 changes: 6 additions & 2 deletions server/portal/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@

import os
import django
from channels.routing import get_default_application
from channels.routing import get_default_application, ProtocolTypeRouter
from django.core.asgi import get_asgi_application


os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'portal.settings.settings')
django.setup()
application = get_default_application()
application = ProtocolTypeRouter({
"http": get_asgi_application(),
})
3 changes: 2 additions & 1 deletion server/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ elasticsearch = "^7.7.1"
uwsgi = "^2.0.22"
requests = "^2.31.0"
django-impersonate = "^1.5"
channels = "^2.4.0"
channels = "^3.0.0"
channels-redis = "^3.1.0"
pytas = {git = "https://bitbucket.org/taccaci/pytas.git", tag = "v1.6.0"}
google-auth = "^1.23.0"
Expand All @@ -46,6 +46,7 @@ pytest-mock = "^3.10.0"
mock = "^5.0.2"
pytest-cov = "^4.0.0"
pytest-django = "^4.5.2"
pytest-asyncio = "^0.21.1"
flake8 = "^6.0.0"
coverage = "^7.2.5"
requests-mock = "^1.10.0"
Expand Down
9 changes: 0 additions & 9 deletions server/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
DJANGO_SETTINGS_MODULE = portal.settings.unit_test_settings
python_files = tests.py *unit_test.py

filterwarnings =
ignore::DeprecationWarning:django.*:
ignore::DeprecationWarning:openapi_schema_validator.*:
ignore::DeprecationWarning:openapi_spec_validator.*:
ignore::DeprecationWarning:openapi_core.*:
ignore::DeprecationWarning:kombu.*:
ignore::DeprecationWarning:pkg_resources.*:
ignore:.*Django now detects this configuration.*:django.utils.deprecation.RemovedInDjango41Warning

markers =
asyncio: mark a test as asyncio.

Expand Down

0 comments on commit 5ce7673

Please sign in to comment.