Tests pour le BDS #816

Open
thubrecht wants to merge 40 commits from thubrecht/bds-tests into master
2 changed files with 13 additions and 9 deletions
Showing only changes of commit 5a28aab7cb - Show all commits

View file

@ -1,3 +1,6 @@
from asgiref.sync import async_to_sync
from channels.layers import get_channel_layer
from .utils import DjangoJsonWebsocketConsumer, PermConsumerMixin
@ -7,3 +10,9 @@ class KPsul(PermConsumerMixin, DjangoJsonWebsocketConsumer):
async def kpsul(self, event):
await self.send_json(event)
@classmethod
@async_to_sync
async def group_send(cls, group, data):
channel_layer = get_channel_layer()
await channel_layer.group_send(group, data)

View file

@ -6,8 +6,6 @@ from decimal import Decimal
from typing import List, Tuple
from urllib.parse import urlencode
from asgiref.sync import async_to_sync
from channels.layers import get_channel_layer
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
@ -37,6 +35,7 @@ from kfet import KFET_DELETED_TRIGRAMME
from kfet.auth.decorators import kfet_password_auth
from kfet.autocomplete import kfet_account_only_autocomplete, kfet_autocomplete
from kfet.config import kfet_config
from kfet.consumers import KPsul
from kfet.decorators import teamkfet_required
from kfet.forms import (
AccountForm,
@ -991,9 +990,8 @@ def kpsul_update_addcost(request):
"type": "kpsul",
}
channel_layer = get_channel_layer()
KPsul.group_send("kfet.kpsul", data)
async_to_sync(channel_layer.group_send)("kfet.kpsul", data)
return JsonResponse(data)
@ -1225,9 +1223,8 @@ def kpsul_perform_operations(request):
{"id": article["id"], "stock": article["stock"]}
)
channel_layer = get_channel_layer()
KPsul.group_send("kfet.kpsul", websocket_data)
async_to_sync(channel_layer.group_send)("kfet.kpsul", websocket_data)
return JsonResponse(data)
@ -1432,9 +1429,7 @@ def cancel_operations(request):
{"id": article["id"], "stock": article["stock"]}
)
channel_layer = get_channel_layer()
async_to_sync(channel_layer.group_send)("kfet.kpsul", websocket_data)
KPsul.group_send("kfet.kpsul", websocket_data)
data["canceled"] = list(opes)
data["opegroups_to_update"] = list(opegroups)