Remove print/console.log statements
This commit is contained in:
parent
86f61e74b5
commit
6ce6a19acf
@ -1,6 +1,7 @@
|
|||||||
import pydantic.json
|
|
||||||
import json
|
import json
|
||||||
from sqlmodel import SQLModel, create_engine, Session, select
|
|
||||||
|
import pydantic.json
|
||||||
|
from sqlmodel import SQLModel, create_engine, Session
|
||||||
|
|
||||||
sqlite_file_name = "database7.db"
|
sqlite_file_name = "database7.db"
|
||||||
sqlite_url = f"sqlite:///{sqlite_file_name}"
|
sqlite_url = f"sqlite:///{sqlite_file_name}"
|
||||||
@ -10,7 +11,7 @@ def _custom_json_serializer(*args, **kwargs) -> str:
|
|||||||
"""
|
"""
|
||||||
Encodes json in the same way that pydantic does.
|
Encodes json in the same way that pydantic does.
|
||||||
"""
|
"""
|
||||||
print('JSON SERIALIZATION')
|
|
||||||
return json.dumps(*args, default=pydantic.json.pydantic_encoder, **kwargs)
|
return json.dumps(*args, default=pydantic.json.pydantic_encoder, **kwargs)
|
||||||
|
|
||||||
engine = create_engine(sqlite_url, echo=False, connect_args={"check_same_thread": False}, json_serializer=_custom_json_serializer)
|
engine = create_engine(sqlite_url, echo=False, connect_args={"check_same_thread": False}, json_serializer=_custom_json_serializer)
|
||||||
|
@ -20,7 +20,7 @@ class FileField(str, metaclass=FileFieldMeta):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate(cls, value: str | IO, values):
|
def validate(cls, value: str | IO, values):
|
||||||
print('VALID FILE', values)
|
|
||||||
upload_root = get_or_create_dir(
|
upload_root = get_or_create_dir(
|
||||||
add_fast_api_root(cls.upload_root))
|
add_fast_api_root(cls.upload_root))
|
||||||
if not isinstance(value, str):
|
if not isinstance(value, str):
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
from fastapi import Query, HTTPException, status
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from typing import IO, List
|
from typing import IO, List
|
||||||
|
|
||||||
|
from fastapi import Depends
|
||||||
|
from fastapi import Query, HTTPException, status
|
||||||
from sqlmodel import Session, select, or_, col
|
from sqlmodel import Session, select, or_, col
|
||||||
from generateur.generateur_main import generate_from_data, generate_from_path
|
|
||||||
from database.auth.models import User
|
from database.auth.models import User
|
||||||
from database.db import get_session
|
from database.db import get_session
|
||||||
from fastapi import Depends
|
from database.exercices.models import ExampleEnum, ExerciceCreate, Exercice, ExerciceEdit, ExercicesTagLink, Tag, \
|
||||||
from database.exercices.models import ExampleEnum, ExerciceCreate, Exercice, ExerciceEdit, ExerciceRead, ExercicesTagLink, Tag, TagCreate, Supports, ExerciceReadFull
|
TagCreate, Supports, ExerciceReadFull
|
||||||
|
from generateur.generateur_main import generate_from_data
|
||||||
from services.auth import get_current_user, get_current_user_optional
|
from services.auth import get_current_user, get_current_user_optional
|
||||||
from services.database import generate_unique_code
|
from services.database import generate_unique_code
|
||||||
from services.io import add_fast_api_root, get_ancestor, get_or_create_dir
|
from services.io import add_fast_api_root, get_ancestor, get_or_create_dir
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create_exo_db(exercice: ExerciceCreate, user: User,supports: Supports, exo_source: IO, db: Session):
|
def create_exo_db(exercice: ExerciceCreate, user: User,supports: Supports, exo_source: IO, db: Session):
|
||||||
example = {
|
example = {
|
||||||
"type": ExampleEnum.csv if supports['csv'] == True else ExampleEnum.web if supports['web'] == True else None,
|
"type": ExampleEnum.csv if supports['csv'] == True else ExampleEnum.web if supports['web'] == True else None,
|
||||||
@ -190,9 +192,9 @@ def serialize_exo(*, exo: Exercice, user_id: User = None, db: Session):
|
|||||||
tags = parse_exo_tags(exo_id=exo.id, user_id=user_id,
|
tags = parse_exo_tags(exo_id=exo.id, user_id=user_id,
|
||||||
db=db) if user_id is not None else []
|
db=db) if user_id is not None else []
|
||||||
is_author = user_id is not None and check_author(exo=exo, user_id=user_id)
|
is_author = user_id is not None and check_author(exo=exo, user_id=user_id)
|
||||||
print('USER', exo.dict(), exo)
|
|
||||||
if exo.original is not None:
|
if exo.original is not None:
|
||||||
print('TEST', db.exec(select(User).where(User.id == exo.original.author_id)).all())
|
|
||||||
author = db.exec(select(User).where(
|
author = db.exec(select(User).where(
|
||||||
User.id == exo.original.author_id)).all()[0]
|
User.id == exo.original.author_id)).all()[0]
|
||||||
original = {**exo.original.dict(), 'author': author.username}
|
original = {**exo.original.dict(), 'author': author.username}
|
||||||
|
@ -286,7 +286,7 @@ def leave_room(member: Member, db: Session):
|
|||||||
def serialize_member(member: Member, private: bool = False, admin: bool = False,
|
def serialize_member(member: Member, private: bool = False, admin: bool = False,
|
||||||
m2: Member | None = None) -> MemberRead | Waiter:
|
m2: Member | None = None) -> MemberRead | Waiter:
|
||||||
member_obj = member.user or member.anonymous
|
member_obj = member.user or member.anonymous
|
||||||
print("OHLA", member_obj, private, member.user_id == None)
|
|
||||||
if not member.waiting:
|
if not member.waiting:
|
||||||
return MemberRead(username=member_obj.username, online=member.online,
|
return MemberRead(username=member_obj.username, online=member.online,
|
||||||
clientId=str(member_obj.clientId) if (private == True and member.user_id == None) else "",
|
clientId=str(member_obj.clientId) if (private == True and member.user_id == None) else "",
|
||||||
@ -379,7 +379,7 @@ def getMemberRank(m: Member, p: Parcours, db: Session):
|
|||||||
|
|
||||||
def getMemberAvgRank(m: Member, p: Parcours, db: Session):
|
def getMemberAvgRank(m: Member, p: Parcours, db: Session):
|
||||||
challenger = db.exec(select(Challenger).where(Challenger.member_id == m.id)).first()
|
challenger = db.exec(select(Challenger).where(Challenger.member_id == m.id)).first()
|
||||||
print('CHALLE', challenger)
|
|
||||||
if challenger is None or challenger.avg is None:
|
if challenger is None or challenger.avg is None:
|
||||||
return None
|
return None
|
||||||
return getAvgRank(challenger, p, db)
|
return getAvgRank(challenger, p, db)
|
||||||
@ -583,8 +583,8 @@ def validate_challenge_input(obj: List[CorrectionData], corr: TmpCorrection):
|
|||||||
for i in range(len(data)):
|
for i in range(len(data)):
|
||||||
exo_corr = data[i]
|
exo_corr = data[i]
|
||||||
exo = obj[i]
|
exo = obj[i]
|
||||||
print('EXO', exo)
|
|
||||||
print('EXO', exo.data)
|
|
||||||
if len(exo.data) != len(exo_corr['data']):
|
if len(exo.data) != len(exo_corr['data']):
|
||||||
return
|
return
|
||||||
zipped = zip(exo_corr['data'], exo.data)
|
zipped = zip(exo_corr['data'], exo.data)
|
||||||
@ -628,7 +628,7 @@ def corrige_challenge(obj: List[List[ParsedGeneratorOut]], corr: TmpCorrection)
|
|||||||
return
|
return
|
||||||
zipped = zip(exo_corr, exo)
|
zipped = zip(exo_corr, exo)
|
||||||
for e, f in zipped:
|
for e, f in zipped:
|
||||||
print("HO\n\n")
|
|
||||||
for k, l in zip(e['inputs'], f.inputs):
|
for k, l in zip(e['inputs'], f.inputs):
|
||||||
k["value"] = str(l.value)
|
k["value"] = str(l.value)
|
||||||
total += 1
|
total += 1
|
||||||
@ -703,7 +703,7 @@ def checkValidated(challenger: Challenger, db: Session, challenge: Challenge | N
|
|||||||
def create_challenge(data: List[CorrigedData], challenger: Member, parcours: Parcours, time: int, mistakes: int,
|
def create_challenge(data: List[CorrigedData], challenger: Member, parcours: Parcours, time: int, mistakes: int,
|
||||||
isCorriged: bool, db: Session):
|
isCorriged: bool, db: Session):
|
||||||
challenger_obj: Challenger = getChallenger(parcours, challenger, db)
|
challenger_obj: Challenger = getChallenger(parcours, challenger, db)
|
||||||
print('VALIDATING', time <= parcours.time * 60 and mistakes <= parcours.max_mistakes, time, parcours.time)
|
|
||||||
validated = time <= parcours.time * 60 and mistakes <= parcours.max_mistakes
|
validated = time <= parcours.time * 60 and mistakes <= parcours.max_mistakes
|
||||||
|
|
||||||
challenge = Challenge(data=data, challenger_pid=challenger_obj.parcours_id, challenger_mid=challenger_obj.member_id,
|
challenge = Challenge(data=data, challenger_pid=challenger_obj.parcours_id, challenger_mid=challenger_obj.member_id,
|
||||||
@ -730,7 +730,7 @@ def create_challenge(data: List[CorrigedData], challenger: Member, parcours: Par
|
|||||||
db.commit()
|
db.commit()
|
||||||
db.refresh(challenge)
|
db.refresh(challenge)
|
||||||
db.refresh(challenger_obj)
|
db.refresh(challenger_obj)
|
||||||
print('RETURN,', challenge, challenger_obj)
|
|
||||||
return challenge, challenger_obj
|
return challenge, challenger_obj
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from typing import BinaryIO, List
|
from typing import BinaryIO
|
||||||
from schemas.exercices import TagIn, TagIn_schema
|
|
||||||
from services.database import generate_unique_code
|
|
||||||
from services.io import add_fast_api_root, get_ancestor, get_filename_from_path, get_parent_dir, remove_fastapi_root, remove_if_exists, get_or_create_dir
|
|
||||||
|
|
||||||
from database.exercices.models import Exercice, Tag
|
from database.exercices.models import Exercice, Tag
|
||||||
from schemas.exercices import Exercice_schema
|
from schemas.exercices import Exercice_schema
|
||||||
|
from services.database import generate_unique_code
|
||||||
|
from services.io import add_fast_api_root, get_ancestor, get_parent_dir, remove_if_exists, get_or_create_dir
|
||||||
|
|
||||||
|
|
||||||
async def create_exo_db(*args, **kwargs) -> Exercice:
|
async def create_exo_db(*args, **kwargs) -> Exercice:
|
||||||
@ -57,14 +55,14 @@ async def clone_exo_db(id_code: str, user_id):
|
|||||||
|
|
||||||
exo_obj = await Exercice_schema.from_tortoise_orm(exo)
|
exo_obj = await Exercice_schema.from_tortoise_orm(exo)
|
||||||
exo_obj = exo_obj.dict(exclude_unset=True)
|
exo_obj = exo_obj.dict(exclude_unset=True)
|
||||||
print("eaoiuezaoiueza", exo_obj)
|
|
||||||
exo_obj.pop('tags')
|
exo_obj.pop('tags')
|
||||||
exo_obj = exclude_dict_key(exo_obj, 'tags')
|
exo_obj = exclude_dict_key(exo_obj, 'tags')
|
||||||
exo_obj = exclude_dict_key(exo_obj, 'author')
|
exo_obj = exclude_dict_key(exo_obj, 'author')
|
||||||
#exo_obj.pop('exercices')
|
#exo_obj.pop('exercices')
|
||||||
|
|
||||||
path = clone_exo_source(exo.exo_source, new_id_code)
|
path = clone_exo_source(exo.exo_source, new_id_code)
|
||||||
print('\n\npatiuar', path, exo_obj, '\n',
|
|
||||||
exclude_dict_key(exo_obj, 'tags'))
|
exclude_dict_key(exo_obj, 'tags'))
|
||||||
new_exo = Exercice(**{**exo_obj, 'id_code': new_id_code, 'exo_source': path,
|
new_exo = Exercice(**{**exo_obj, 'id_code': new_id_code, 'exo_source': path,
|
||||||
"isOriginal": False, 'author_id': user_id}, origin_id=exo.id)
|
"isOriginal": False, 'author_id': user_id}, origin_id=exo.id)
|
||||||
|
@ -7,6 +7,6 @@ def exos(nb, username, password):
|
|||||||
for i in range(nb):
|
for i in range(nb):
|
||||||
r = requests.post('http://localhost:8002/exercices', data={"name": "Test" + str(i), "consigne": "consigne", "private": False}, files={
|
r = requests.post('http://localhost:8002/exercices', data={"name": "Test" + str(i), "consigne": "consigne", "private": False}, files={
|
||||||
'file': ('test.py', open('./tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test.py', open('./tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print('DONE')
|
|
||||||
|
|
||||||
exos(100, "lilianTest2", "Pomme937342")
|
exos(100, "lilianTest2", "Pomme937342")
|
@ -37,7 +37,7 @@ def Csv_generator(path, nb_in_serie, nb_page, police, consigne, writer):
|
|||||||
if len(text_longueur) > longueur_max:
|
if len(text_longueur) > longueur_max:
|
||||||
consigne_lines.append(text_longueur)
|
consigne_lines.append(text_longueur)
|
||||||
text_longueur = ''
|
text_longueur = ''
|
||||||
# print(text_longueur)
|
#
|
||||||
else:
|
else:
|
||||||
consigne_lines.append(consigne)
|
consigne_lines.append(consigne)
|
||||||
serie_page_vertical = int(PAGE_LINES[police] /
|
serie_page_vertical = int(PAGE_LINES[police] /
|
||||||
|
@ -62,7 +62,7 @@ class Id_codeField(str):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate(cls, value, values, config, field):
|
def validate(cls, value, values, config, field):
|
||||||
print("validator", cls, value, values, config, field)
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
class Test(SQLModel, table=True):
|
class Test(SQLModel, table=True):
|
||||||
@ -71,13 +71,13 @@ class Test(SQLModel, table=True):
|
|||||||
|
|
||||||
''' @validator('id_code', always=True)
|
''' @validator('id_code', always=True)
|
||||||
def test(cls,value, values):
|
def test(cls,value, values):
|
||||||
print('VAlIDATE')
|
|
||||||
session= get_session()
|
session= get_session()
|
||||||
session = next(session)
|
session = next(session)
|
||||||
y = session.exec(select(cls)).all()
|
y = session.exec(select(cls)).all()
|
||||||
print(y)
|
|
||||||
code = generate_unique_code(cls, s=session)
|
code = generate_unique_code(cls, s=session)
|
||||||
print(code)
|
|
||||||
return code '''
|
return code '''
|
||||||
|
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
@ -100,7 +100,7 @@ def test(test_1: str, test_2: str, test_3: str = Depends(t), test_4: str = Depen
|
|||||||
@app.exception_handler(ValidationError)
|
@app.exception_handler(ValidationError)
|
||||||
async def validation_exception_handler(request: Request, exc: RequestValidationError|ValidationError):
|
async def validation_exception_handler(request: Request, exc: RequestValidationError|ValidationError):
|
||||||
errors = {}
|
errors = {}
|
||||||
print(exc.errors())
|
|
||||||
for e in exc.errors():
|
for e in exc.errors():
|
||||||
locs = [e for e in e['loc'] if type(e) == str]
|
locs = [e for e in e['loc'] if type(e) == str]
|
||||||
errors[locs[-1] + "_error"] = e['msg']
|
errors[locs[-1] + "_error"] = e['msg']
|
||||||
|
@ -120,7 +120,7 @@ def get_public_exercices(user: User | None = Depends(get_current_user_optional),
|
|||||||
statement = statement.where(sub)
|
statement = statement.where(sub)
|
||||||
statement = statement.order_by(col(Exercice.id).desc())
|
statement = statement.order_by(col(Exercice.id).desc())
|
||||||
page = p(db, statement)
|
page = p(db, statement)
|
||||||
print('¨PAGE', page)
|
|
||||||
exercices = page.items
|
exercices = page.items
|
||||||
page.items = [
|
page.items = [
|
||||||
serialize_exo(exo=e, user_id=user.id, db=db) for e in exercices]
|
serialize_exo(exo=e, user_id=user.id, db=db) for e in exercices]
|
||||||
|
@ -8,7 +8,7 @@ from database.auth.crud import get_user_from_token
|
|||||||
from database.room.crud import change_room_name, change_room_status, serialize_member, check_user_in_room, \
|
from database.room.crud import change_room_name, change_room_status, serialize_member, check_user_in_room, \
|
||||||
create_anonymous, create_member, get_member, get_member_from_token, get_member_from_reconnect_code, connect_member, \
|
create_anonymous, create_member, get_member, get_member_from_token, get_member_from_reconnect_code, connect_member, \
|
||||||
disconnect_member, get_waiter, accept_waiter, leave_room, refuse_waiter
|
disconnect_member, get_waiter, accept_waiter, leave_room, refuse_waiter
|
||||||
from database.room.models import Room, Member, MemberRead, Waiter, Challenger
|
from database.room.models import Room, Member, MemberRead, Waiter
|
||||||
from services.websocket import Consumer
|
from services.websocket import Consumer
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@ -69,11 +69,11 @@ class RoomConsumer(Consumer):
|
|||||||
# await self.broadcast(type="connect", payload={"member": serialize_member(self.member)}, exclude=True)
|
# await self.broadcast(type="connect", payload={"member": serialize_member(self.member)}, exclude=True)
|
||||||
|
|
||||||
async def disconnect_self(self):
|
async def disconnect_self(self):
|
||||||
print(self.manager.active_connections[self.room.id_code])
|
|
||||||
self.manager.remove(self.room.id_code, self)
|
self.manager.remove(self.room.id_code, self)
|
||||||
print(self.manager.active_connections[self.room.id_code])
|
|
||||||
if isinstance(self.member, Member):
|
if isinstance(self.member, Member):
|
||||||
print('MEMBER', self.member)
|
|
||||||
try:
|
try:
|
||||||
disconnect_member(self.member, self.db)
|
disconnect_member(self.member, self.db)
|
||||||
except StaleDataError:
|
except StaleDataError:
|
||||||
@ -111,7 +111,7 @@ class RoomConsumer(Consumer):
|
|||||||
return self.member is not None and self.member.is_admin == True
|
return self.member is not None and self.member.is_admin == True
|
||||||
|
|
||||||
async def isMember(self):
|
async def isMember(self):
|
||||||
print('S', self.member, self.ws, self.ws.state, self.ws.application_state.__str__())
|
|
||||||
if self.member is None:
|
if self.member is None:
|
||||||
await self.send_error("Vous n'êtes connecté à aucune salle")
|
await self.send_error("Vous n'êtes connecté à aucune salle")
|
||||||
return self.member is not None and self.member.waiting == False
|
return self.member is not None and self.member.waiting == False
|
||||||
@ -126,10 +126,10 @@ class RoomConsumer(Consumer):
|
|||||||
if reconnect_code is None and token is None:
|
if reconnect_code is None and token is None:
|
||||||
await self.direct_send(type="error", payload={"msg": "Veuillez spécifier une méthode de connection"})
|
await self.direct_send(type="error", payload={"msg": "Veuillez spécifier une méthode de connection"})
|
||||||
return
|
return
|
||||||
print("login", token)
|
|
||||||
if token is not None:
|
if token is not None:
|
||||||
member = get_member_from_token(token, self.room.id, self.db)
|
member = get_member_from_token(token, self.room.id, self.db)
|
||||||
print('MEMBER', member)
|
|
||||||
if member == False:
|
if member == False:
|
||||||
await self.send_error("Token expired", code=422)
|
await self.send_error("Token expired", code=422)
|
||||||
return
|
return
|
||||||
@ -233,7 +233,7 @@ class RoomConsumer(Consumer):
|
|||||||
async def change_name(self, name: str):
|
async def change_name(self, name: str):
|
||||||
if len(name) < 20:
|
if len(name) < 20:
|
||||||
self.room = change_room_name(self.room, name, self.db)
|
self.room = change_room_name(self.room, name, self.db)
|
||||||
print('SENDING')
|
|
||||||
await self.broadcast(type="new_name", payload={"name": name})
|
await self.broadcast(type="new_name", payload={"name": name})
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -251,7 +251,7 @@ class RoomConsumer(Consumer):
|
|||||||
|
|
||||||
@Consumer.event('leave', conditions=[isMember])
|
@Consumer.event('leave', conditions=[isMember])
|
||||||
async def leave(self):
|
async def leave(self):
|
||||||
print('LEAVED', self.member, isinstance(self.member, Member), isinstance(self.member, Challenger))
|
|
||||||
if self.member.is_admin is True:
|
if self.member.is_admin is True:
|
||||||
await self.send_error("Vous ne pouvez pas quitter une salle dont vous êtes l'administrateur")
|
await self.send_error("Vous ne pouvez pas quitter une salle dont vous êtes l'administrateur")
|
||||||
return
|
return
|
||||||
@ -316,8 +316,8 @@ class RoomConsumer(Consumer):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
async def disconnect(self):
|
async def disconnect(self):
|
||||||
print('DISCONNECTED', self.member)
|
|
||||||
print(self.manager.active_connections[self.room.id_code])
|
|
||||||
self.manager.remove(self.room.id_code, self)
|
self.manager.remove(self.room.id_code, self)
|
||||||
|
|
||||||
for p in self.room.parcours:
|
for p in self.room.parcours:
|
||||||
|
@ -18,7 +18,7 @@ class RoomManager:
|
|||||||
self.active_connections[group].append(member)
|
self.active_connections[group].append(member)
|
||||||
|
|
||||||
async def _send(self, connection: "RoomConsumer", message, group: str):
|
async def _send(self, connection: "RoomConsumer", message, group: str):
|
||||||
print('SENDING', connection.ws.application_state, connection.ws.client_state)
|
|
||||||
if connection.ws.application_state == WebSocketState.DISCONNECTED or connection.ws.client_state == WebSocketState.DISCONNECTED:
|
if connection.ws.application_state == WebSocketState.DISCONNECTED or connection.ws.client_state == WebSocketState.DISCONNECTED:
|
||||||
self.remove(group, connection)
|
self.remove(group, connection)
|
||||||
elif connection.ws.application_state == WebSocketState.CONNECTED and connection.ws.client_state == WebSocketState.CONNECTED:
|
elif connection.ws.application_state == WebSocketState.CONNECTED and connection.ws.client_state == WebSocketState.CONNECTED:
|
||||||
@ -34,7 +34,7 @@ class RoomManager:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
async def broadcast(self, message: Any | Callable, group: str, conditions: list[Callable] = [], exclude: list["RoomConsumer"] = [], ):
|
async def broadcast(self, message: Any | Callable, group: str, conditions: list[Callable] = [], exclude: list["RoomConsumer"] = [], ):
|
||||||
print('BROADCaST', self.active_connections)
|
|
||||||
|
|
||||||
|
|
||||||
if group in self.active_connections:
|
if group in self.active_connections:
|
||||||
@ -43,17 +43,17 @@ class RoomManager:
|
|||||||
await self._send(connection, message, group)
|
await self._send(connection, message, group)
|
||||||
|
|
||||||
async def send_to(self, group, id_code, msg):
|
async def send_to(self, group, id_code, msg):
|
||||||
print('SENDING TO')
|
|
||||||
if group in self.active_connections:
|
if group in self.active_connections:
|
||||||
members = [c for c in self.active_connections[group]
|
members = [c for c in self.active_connections[group]
|
||||||
if c.member.id_code == id_code]
|
if c.member.id_code == id_code]
|
||||||
print('MEM', members)
|
|
||||||
for m in members:
|
for m in members:
|
||||||
await self._send(m, msg, group)
|
await self._send(m, msg, group)
|
||||||
|
|
||||||
async def send_to_admin(self, group, msg):
|
async def send_to_admin(self, group, msg):
|
||||||
if group in self.active_connections:
|
if group in self.active_connections:
|
||||||
print('MEMBERS', self.active_connections[group], [(c.ws.state, c.ws.client_state, c.ws.application_state) for c in self.active_connections[group]])
|
|
||||||
members = [c for c in self.active_connections[group]
|
members = [c for c in self.active_connections[group]
|
||||||
if c.member is not None and c.member.is_admin is True]
|
if c.member is not None and c.member.is_admin is True]
|
||||||
for m in members:
|
for m in members:
|
||||||
|
@ -90,7 +90,7 @@ async def update_parcours(*, room_id: str, parcours: ParcoursCreate, member: Mem
|
|||||||
await m.broadcast({"type": "edit_parcours", "data": {
|
await m.broadcast({"type": "edit_parcours", "data": {
|
||||||
"parcours": ParcoursReadUpdate(**parcours_obj.dict(), update_challenges=update_challenges).dict()}},
|
"parcours": ParcoursReadUpdate(**parcours_obj.dict(), update_challenges=update_challenges).dict()}},
|
||||||
parcours_old.id_code)
|
parcours_old.id_code)
|
||||||
print('BROADCASTING')
|
|
||||||
await m.broadcast(
|
await m.broadcast(
|
||||||
lambda m: {"type": "update_challenges", "data": {"challenger": {"id_code": m.id_code, "name": getUsername(m), "validated": getMemberValidated(m, parcours_obj, db)},
|
lambda m: {"type": "update_challenges", "data": {"challenger": {"id_code": m.id_code, "name": getUsername(m), "validated": getMemberValidated(m, parcours_obj, db)},
|
||||||
"challenges": [Challenges(
|
"challenges": [Challenges(
|
||||||
@ -118,7 +118,7 @@ class Exos(BaseModel):
|
|||||||
@router.get('/room/{room_id}/challenge/{parcours_id}')
|
@router.get('/room/{room_id}/challenge/{parcours_id}')
|
||||||
def challenge_route(parcours: Parcours = Depends(get_parcours), exercices: List[Exos] = Depends(get_exercices),
|
def challenge_route(parcours: Parcours = Depends(get_parcours), exercices: List[Exos] = Depends(get_exercices),
|
||||||
member: Member = Depends(get_member_dep), db: Session = Depends(get_session)):
|
member: Member = Depends(get_member_dep), db: Session = Depends(get_session)):
|
||||||
print('GENERATE', exercices)
|
|
||||||
correction = [parseGeneratorOut(generate_from_path(add_fast_api_root(
|
correction = [parseGeneratorOut(generate_from_path(add_fast_api_root(
|
||||||
e['exercice'].exo_source), e['quantity'], "web")) for e in exercices]
|
e['exercice'].exo_source), e['quantity'], "web")) for e in exercices]
|
||||||
|
|
||||||
@ -161,21 +161,21 @@ async def send_challenge(*, challenge: List[CorrectionData], correction: TmpCorr
|
|||||||
await m.broadcast(lambda m: {"type": "newRanks", "data": {"rank": getMemberRank(m, correction.parcours, db),
|
await m.broadcast(lambda m: {"type": "newRanks", "data": {"rank": getMemberRank(m, correction.parcours, db),
|
||||||
"avgRank": getMemberAvgRank(m, correction.parcours, db)}},
|
"avgRank": getMemberAvgRank(m, correction.parcours, db)}},
|
||||||
parcours.id_code)
|
parcours.id_code)
|
||||||
print('WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOoo')
|
|
||||||
await m.send_to(parcours.room.id_code, member.id_code, {"type": "parcours_stats", "data": {
|
await m.send_to(parcours.room.id_code, member.id_code, {"type": "parcours_stats", "data": {
|
||||||
"parcours": ParcoursReadShort(name=parcours.name, best_note=challenger.best, validated=challenger.validated,
|
"parcours": ParcoursReadShort(name=parcours.name, best_note=challenger.best, validated=challenger.validated,
|
||||||
id_code=parcours.id_code, avg=challenger.avg).dict()}})
|
id_code=parcours.id_code, avg=challenger.avg).dict()}})
|
||||||
|
|
||||||
print('CHALLENGE', chall)
|
|
||||||
rank, avgRank = getRank(
|
rank, avgRank = getRank(
|
||||||
challenger, parcours, db), getAvgRank(challenger, parcours, db)
|
challenger, parcours, db), getAvgRank(challenger, parcours, db)
|
||||||
print('RANKS', rank, avgRank)
|
|
||||||
if rank <= 3 or avgRank <= 3:
|
if rank <= 3 or avgRank <= 3:
|
||||||
await m.broadcast({"type": "newTops", "data": {
|
await m.broadcast({"type": "newTops", "data": {
|
||||||
"tops": getTops(correction.parcours, db),
|
"tops": getTops(correction.parcours, db),
|
||||||
"avgTops": getAvgTops(correction.parcours, db),
|
"avgTops": getAvgTops(correction.parcours, db),
|
||||||
}}, parcours.id_code)
|
}}, parcours.id_code)
|
||||||
print('CHALLENGE', chall)
|
|
||||||
db.delete(correction)
|
db.delete(correction)
|
||||||
returnValue = {**chall.dict()}
|
returnValue = {**chall.dict()}
|
||||||
db.commit()
|
db.commit()
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from math import ceil
|
||||||
from typing import TypeVar, Generic, Sequence
|
from typing import TypeVar, Generic, Sequence
|
||||||
|
|
||||||
from fastapi_pagination import Params
|
from fastapi_pagination import Params
|
||||||
from fastapi_pagination.bases import AbstractPage, AbstractParams, BasePage
|
from fastapi_pagination.bases import AbstractParams, BasePage
|
||||||
from math import ceil
|
|
||||||
from pydantic import conint
|
from pydantic import conint
|
||||||
|
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
@ -24,7 +25,7 @@ class Page(BasePage[T], Generic[T]):
|
|||||||
total: int,
|
total: int,
|
||||||
params: AbstractParams,
|
params: AbstractParams,
|
||||||
) -> Page[T]:
|
) -> Page[T]:
|
||||||
print("PARAMS", params)
|
|
||||||
totalPage = ceil(total/params.size)
|
totalPage = ceil(total/params.size)
|
||||||
return cls(
|
return cls(
|
||||||
total=total,
|
total=total,
|
||||||
|
@ -74,7 +74,7 @@ class Consumer:
|
|||||||
''' if self.ws.state == WebSocketState.DISCONNECTED:
|
''' if self.ws.state == WebSocketState.DISCONNECTED:
|
||||||
return '''
|
return '''
|
||||||
type = payload.get('type', None)
|
type = payload.get('type', None)
|
||||||
print('TYPE', type, self.member)
|
|
||||||
|
|
||||||
if type is not None:
|
if type is not None:
|
||||||
event_wrapper = self.sendings.get(type, None)
|
event_wrapper = self.sendings.get(type, None)
|
||||||
@ -91,7 +91,7 @@ class Consumer:
|
|||||||
try:
|
try:
|
||||||
validated_payload = model(self=self, **data)
|
validated_payload = model(self=self, **data)
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
print("ERROR", e)
|
|
||||||
await self.ws.send_json({"type": "error", "data": {"msg": "Oops there was an error"}})
|
await self.ws.send_json({"type": "error", "data": {"msg": "Oops there was an error"}})
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -142,5 +142,5 @@ class Consumer:
|
|||||||
data = await self.ws.receive_json()
|
data = await self.ws.receive_json()
|
||||||
await self.receive(data)
|
await self.receive(data)
|
||||||
except WebSocketDisconnect:
|
except WebSocketDisconnect:
|
||||||
print('DISCONNECTION')
|
|
||||||
await self.disconnect()
|
await self.disconnect()
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
t = "test = 12"
|
t = "test = 12"
|
||||||
locs ={}
|
locs ={}
|
||||||
exec(t, globals(), locs)
|
exec(t, globals(), locs)
|
||||||
print(locs)
|
|
@ -6,7 +6,7 @@ VALID_PASSWORD = 'Test12345'
|
|||||||
def test_register(client: TestClient, username = VALID_USERNAME):
|
def test_register(client: TestClient, username = VALID_USERNAME):
|
||||||
r = client.post('/register', data={"username": username, 'password': VALID_PASSWORD, 'password_confirm': VALID_PASSWORD})
|
r = client.post('/register', data={"username": username, 'password': VALID_PASSWORD, 'password_confirm': VALID_PASSWORD})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert 'access_token' in data
|
assert 'access_token' in data
|
||||||
assert 'refresh_token' in data
|
assert 'refresh_token' in data
|
||||||
@ -16,7 +16,7 @@ def test_register_username_too_long(client: TestClient):
|
|||||||
r = client.post('/register', data={"username": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
r = client.post('/register', data={"username": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||||
'password':VALID_PASSWORD, 'password_confirm':VALID_PASSWORD})
|
'password':VALID_PASSWORD, 'password_confirm':VALID_PASSWORD})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert data['detail']['username_error'] == 'ensure this value has at most 20 characters'
|
assert data['detail']['username_error'] == 'ensure this value has at most 20 characters'
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ def test_register_mdp_not_corresponding(client: TestClient):
|
|||||||
r = client.post('/register', data={"username": VALID_USERNAME,
|
r = client.post('/register', data={"username": VALID_USERNAME,
|
||||||
'password': "Test12345", 'password_confirm': 'Test1234'})
|
'password': "Test12345", 'password_confirm': 'Test1234'})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert data['detail']['password_confirm_error'] == 'Les mots de passe ne correspondent pas'
|
assert data['detail']['password_confirm_error'] == 'Les mots de passe ne correspondent pas'
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ def test_register_mdp_missing_number(client: TestClient):
|
|||||||
r = client.post('/register', data={"username": "lilian",
|
r = client.post('/register', data={"username": "lilian",
|
||||||
'password': "Testttttt", 'password_confirm': 'Testttttt'})
|
'password': "Testttttt", 'password_confirm': 'Testttttt'})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert data['detail']['password_error'] == 'Le mot de passe doit contenir au moins un chiffre'
|
assert data['detail']['password_error'] == 'Le mot de passe doit contenir au moins un chiffre'
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ def test_register_mdp_missing_maj(client: TestClient):
|
|||||||
r = client.post('/register', data={"username":VALID_USERNAME,
|
r = client.post('/register', data={"username":VALID_USERNAME,
|
||||||
'password': "testttttt1", 'password_confirm': 'testttttt1'})
|
'password': "testttttt1", 'password_confirm': 'testttttt1'})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert data['detail']['password_error'] == 'Le mot de passe doit contenir au moins une majuscule'
|
assert data['detail']['password_error'] == 'Le mot de passe doit contenir au moins une majuscule'
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ def test_register_mdp_too_short(client: TestClient):
|
|||||||
r = client.post('/register', data={"username": VALID_USERNAME,
|
r = client.post('/register', data={"username": VALID_USERNAME,
|
||||||
'password': "t", 'password_confirm': 't'})
|
'password': "t", 'password_confirm': 't'})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert data['detail'][
|
assert data['detail'][
|
||||||
'password_error'] == 'Le mot de passe est trop court (8 caractères minimum)'
|
'password_error'] == 'Le mot de passe est trop court (8 caractères minimum)'
|
||||||
@ -60,7 +60,7 @@ def test_register_username_indisponible(client: TestClient):
|
|||||||
rr = client.post('/register', data={"username": VALID_USERNAME,
|
rr = client.post('/register', data={"username": VALID_USERNAME,
|
||||||
'password':VALID_PASSWORD, 'password_confirm':VALID_PASSWORD})
|
'password':VALID_PASSWORD, 'password_confirm':VALID_PASSWORD})
|
||||||
data = rr.json()
|
data = rr.json()
|
||||||
print(data)
|
|
||||||
assert rr.status_code == 400
|
assert rr.status_code == 400
|
||||||
assert data['detail'][
|
assert data['detail'][
|
||||||
'username_error'] == "Nom d'utilisateur indisponible"
|
'username_error'] == "Nom d'utilisateur indisponible"
|
||||||
@ -70,7 +70,7 @@ def test_login(client: TestClient):
|
|||||||
|
|
||||||
r = client.post('/login', data={"username": VALID_USERNAME, 'password': VALID_PASSWORD})
|
r = client.post('/login', data={"username": VALID_USERNAME, 'password': VALID_PASSWORD})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert 'access_token' in data
|
assert 'access_token' in data
|
||||||
assert 'refresh_token' in data
|
assert 'refresh_token' in data
|
||||||
@ -81,7 +81,7 @@ def test_login_invalid_password(client: TestClient):
|
|||||||
|
|
||||||
r = client.post('/login', data={"username": VALID_USERNAME, 'password': 'Test1234'})
|
r = client.post('/login', data={"username": VALID_USERNAME, 'password': 'Test1234'})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 401
|
assert r.status_code == 401
|
||||||
assert data['detail'][
|
assert data['detail'][
|
||||||
'password_error'] == "Mot de passe invalide"
|
'password_error'] == "Mot de passe invalide"
|
||||||
@ -89,7 +89,7 @@ def test_login_invalid_password(client: TestClient):
|
|||||||
def test_login_user_not_found(client: TestClient):
|
def test_login_user_not_found(client: TestClient):
|
||||||
r = client.post('/login', data={"username": VALID_USERNAME, 'password': VALID_PASSWORD})
|
r = client.post('/login', data={"username": VALID_USERNAME, 'password': VALID_PASSWORD})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 401
|
assert r.status_code == 401
|
||||||
assert data['detail'][
|
assert data['detail'][
|
||||||
'username_error'] == "Utilisateur introuvable"
|
'username_error'] == "Utilisateur introuvable"
|
||||||
@ -101,7 +101,7 @@ def test_check_token(client: TestClient):
|
|||||||
r = client.post(
|
r = client.post(
|
||||||
'/check-access', headers={'Authorization': 'Bearer ' + token})
|
'/check-access', headers={'Authorization': 'Bearer ' + token})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert data['username'] == 'lilian'
|
assert data['username'] == 'lilian'
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ def test_update_user(client: TestClient):
|
|||||||
r = client.put(
|
r = client.put(
|
||||||
'/user', headers={'Authorization': 'Bearer ' + token}, data= {'username': 'lilian2', 'email': 'example@example.com', 'firstname': 'test', 'name': "test"})
|
'/user', headers={'Authorization': 'Bearer ' + token}, data= {'username': 'lilian2', 'email': 'example@example.com', 'firstname': 'test', 'name': "test"})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert data['username'] == 'lilian2'
|
assert data['username'] == 'lilian2'
|
||||||
assert data['email'] == 'example@example.com'
|
assert data['email'] == 'example@example.com'
|
||||||
@ -135,7 +135,7 @@ def test_update_user_invalid(client: TestClient):
|
|||||||
r = client.put(
|
r = client.put(
|
||||||
'/user', headers={'Authorization': 'Bearer ' + token}, data={'username': 'lilian222222222222222', 'email': 'example@example.com', 'firstname': 'test', 'name': "test"})
|
'/user', headers={'Authorization': 'Bearer ' + token}, data={'username': 'lilian222222222222222', 'email': 'example@example.com', 'firstname': 'test', 'name': "test"})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert data['detail']['username_error'] == 'ensure this value has at most 20 characters'
|
assert data['detail']['username_error'] == 'ensure this value has at most 20 characters'
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ def test_update_username_missing(client: TestClient):
|
|||||||
r = client.put(
|
r = client.put(
|
||||||
'/user', headers={'Authorization': 'Bearer ' + token}, data={ 'email': 'example@example.com', 'firstname': 'test', 'name': "test"})
|
'/user', headers={'Authorization': 'Bearer ' + token}, data={ 'email': 'example@example.com', 'firstname': 'test', 'name': "test"})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert data['detail']['username_error'] == 'field required'
|
assert data['detail']['username_error'] == 'field required'
|
||||||
def test_update_username_missing(client: TestClient):
|
def test_update_username_missing(client: TestClient):
|
||||||
@ -153,7 +153,7 @@ def test_update_username_missing(client: TestClient):
|
|||||||
r = client.put(
|
r = client.put(
|
||||||
'/user', data={ 'email': 'example@example.com', 'firstname': 'test', 'name': "test"})
|
'/user', data={ 'email': 'example@example.com', 'firstname': 'test', 'name': "test"})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 401
|
assert r.status_code == 401
|
||||||
assert data['detail'] == 'Not authenticated'
|
assert data['detail'] == 'Not authenticated'
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ def test_delete_user(client: TestClient):
|
|||||||
'/user', data={'username': VALID_USERNAME, 'password': VALID_PASSWORD})
|
'/user', data={'username': VALID_USERNAME, 'password': VALID_PASSWORD})
|
||||||
|
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert data['ok'] == True
|
assert data['ok'] == True
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ def test_delete_invalid_password(client: TestClient):
|
|||||||
r = client.delete(
|
r = client.delete(
|
||||||
'/user', data={"username": VALID_USERNAME, 'password': 'Test1234'})
|
'/user', data={"username": VALID_USERNAME, 'password': 'Test1234'})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 401
|
assert r.status_code == 401
|
||||||
assert data['detail'][
|
assert data['detail'][
|
||||||
'password_error'] == "Mot de passe invalide"
|
'password_error'] == "Mot de passe invalide"
|
||||||
@ -189,7 +189,7 @@ def test_delete_user_not_found(client: TestClient):
|
|||||||
r = client.delete(
|
r = client.delete(
|
||||||
'/user', data={"username": VALID_USERNAME, 'password': VALID_PASSWORD})
|
'/user', data={"username": VALID_USERNAME, 'password': VALID_PASSWORD})
|
||||||
data = r.json()
|
data = r.json()
|
||||||
print(data)
|
|
||||||
assert r.status_code == 401
|
assert r.status_code == 401
|
||||||
assert data['detail'][
|
assert data['detail'][
|
||||||
'username_error'] == "Utilisateur introuvable"
|
'username_error'] == "Utilisateur introuvable"
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
from pydantic import BaseModel
|
|
||||||
import time
|
|
||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from tests.test_auth import test_register
|
from tests.test_auth import test_register
|
||||||
|
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ def test_create(client: TestClient, name="test_exo", consigne="consigne", privat
|
|||||||
username = user['username']
|
username = user['username']
|
||||||
r = client.post('/exercices', data={"name": name, "consigne": consigne, "private": private}, files={
|
r = client.post('/exercices', data={"name": name, "consigne": consigne, "private": private}, files={
|
||||||
'file': ('test.py', open('tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test.py', open('tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 201
|
assert r.status_code == 201
|
||||||
assert 'id_code' in r.json()
|
assert 'id_code' in r.json()
|
||||||
assert {**r.json(), 'id_code': None} == {'name': name, 'consigne': consigne, 'private': private, 'id_code': None, 'author': {'username': username}, 'original': None, 'tags': [], 'exo_source': 'test.py', 'supports': {
|
assert {**r.json(), 'id_code': None} == {'name': name, 'consigne': consigne, 'private': private, 'id_code': None, 'author': {'username': username}, 'original': None, 'tags': [], 'exo_source': 'test.py', 'supports': {
|
||||||
@ -32,7 +33,7 @@ def test_create_bad_import(client: TestClient, name="test_exo", consigne="consig
|
|||||||
username = user['username']
|
username = user['username']
|
||||||
r = client.post('/exercices', data={"name": name, "consigne": consigne, "private": private}, files={
|
r = client.post('/exercices', data={"name": name, "consigne": consigne, "private": private}, files={
|
||||||
'file': ('test.py', open('tests/testing_exo_source/exo_source_bad_import.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test.py', open('tests/testing_exo_source/exo_source_bad_import.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ def test_create_bad_use__(client: TestClient, name="test_exo", consigne="consign
|
|||||||
username = user['username']
|
username = user['username']
|
||||||
r = client.post('/exercices', data={"name": name, "consigne": consigne, "private": private}, files={
|
r = client.post('/exercices', data={"name": name, "consigne": consigne, "private": private}, files={
|
||||||
'file': ('test.py', open('tests/testing_exo_source/exo_source_use__.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test.py', open('tests/testing_exo_source/exo_source_use__.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ def test_create_invalid(client: TestClient):
|
|||||||
|
|
||||||
r = client.post('/exercices', data={"name": "e"*51, "consigne": "e"*201, "private": False}, files={
|
r = client.post('/exercices', data={"name": "e"*51, "consigne": "e"*201, "private": False}, files={
|
||||||
'file': ('test.py', open('tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test.py', open('tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print('RESP', r.json())
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert r.json()['detail'] == {'name_error': 'ensure this value has at most 50 characters',
|
assert r.json()['detail'] == {'name_error': 'ensure this value has at most 50 characters',
|
||||||
'consigne_error': 'ensure this value has at most 200 characters'}
|
'consigne_error': 'ensure this value has at most 200 characters'}
|
||||||
@ -70,7 +71,7 @@ def test_create_too_long(client: TestClient):
|
|||||||
|
|
||||||
r = client.post('/exercices', data={"name": "e", "consigne": "e", "private": False}, files={
|
r = client.post('/exercices', data={"name": "e", "consigne": "e", "private": False}, files={
|
||||||
'file': ('test.py', open('tests/testing_exo_source/exo_source_infinite.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test.py', open('tests/testing_exo_source/exo_source_infinite.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print('RESP', r.json())
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert r.json()['detail'] == {'exo_source_error': 'Script took too long', }
|
assert r.json()['detail'] == {'exo_source_error': 'Script took too long', }
|
||||||
|
|
||||||
@ -79,7 +80,7 @@ def test_create_name_missing(client: TestClient):
|
|||||||
token = test_register(client)['access']
|
token = test_register(client)['access']
|
||||||
|
|
||||||
r = client.post('/exercices', headers={"Authorization": "Bearer " + token})
|
r = client.post('/exercices', headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert r.json()['detail'] == {
|
assert r.json()['detail'] == {
|
||||||
'name_error': 'field required', 'file_error': 'field required'}
|
'name_error': 'field required', 'file_error': 'field required'}
|
||||||
@ -90,7 +91,7 @@ def test_create_missing_main(client: TestClient):
|
|||||||
|
|
||||||
r = client.post('/exercices', data={"name": "test_exo", "consigne": "consigne", "private": False}, files={
|
r = client.post('/exercices', data={"name": "test_exo", "consigne": "consigne", "private": False}, files={
|
||||||
'file': ('test.py', open('tests/testing_exo_source/exo_source_missing_main.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test.py', open('tests/testing_exo_source/exo_source_missing_main.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert r.json()['detail'] == {
|
assert r.json()['detail'] == {
|
||||||
'exo_source_error': "Fonction 'main' introuvable"}
|
'exo_source_error': "Fonction 'main' introuvable"}
|
||||||
@ -101,7 +102,7 @@ def test_create_invalid_source(client: TestClient):
|
|||||||
|
|
||||||
r = client.post('/exercices', data={"name": "test_exo", "consigne": "consigne", "private": False}, files={
|
r = client.post('/exercices', data={"name": "test_exo", "consigne": "consigne", "private": False}, files={
|
||||||
'file': ('test.py', open('tests/testing_exo_source/exo_source_invalid.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test.py', open('tests/testing_exo_source/exo_source_invalid.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert r.json()['detail'] == {
|
assert r.json()['detail'] == {
|
||||||
'exo_source_error': "Exercice non valide (compatible avec aucun support)"}
|
'exo_source_error': "Exercice non valide (compatible avec aucun support)"}
|
||||||
@ -113,7 +114,7 @@ def test_clone(client: TestClient):
|
|||||||
token = test_register(client, username="lilian2")['access']
|
token = test_register(client, username="lilian2")['access']
|
||||||
rr = client.post('/clone/' + id_code,
|
rr = client.post('/clone/' + id_code,
|
||||||
headers={'Authorization': 'Bearer ' + token})
|
headers={'Authorization': 'Bearer ' + token})
|
||||||
print(rr.json())
|
|
||||||
assert rr.status_code == 200
|
assert rr.status_code == 200
|
||||||
assert 'id_code' in rr.json()
|
assert 'id_code' in rr.json()
|
||||||
assert {**rr.json(), 'id_code': None} == {'name': 'test_exo', 'consigne': 'consigne', 'private': False, 'id_code': None, 'author': {'username': 'lilian2'}, 'original': {"id_code": id_code, "name": create['name'], 'author': 'lilian'}, 'tags': [], 'exo_source': 'test.py', 'supports': {
|
assert {**rr.json(), 'id_code': None} == {'name': 'test_exo', 'consigne': 'consigne', 'private': False, 'id_code': None, 'author': {'username': 'lilian2'}, 'original': {"id_code": id_code, "name": create['name'], 'author': 'lilian'}, 'tags': [], 'exo_source': 'test.py', 'supports': {
|
||||||
@ -126,7 +127,7 @@ def test_clone_private(client: TestClient):
|
|||||||
token = test_register(client, username="lilian2")['access']
|
token = test_register(client, username="lilian2")['access']
|
||||||
rr = client.post('/clone/' + id_code,
|
rr = client.post('/clone/' + id_code,
|
||||||
headers={'Authorization': 'Bearer ' + token})
|
headers={'Authorization': 'Bearer ' + token})
|
||||||
print(rr.json())
|
|
||||||
assert rr.status_code == 401
|
assert rr.status_code == 401
|
||||||
assert rr.json() == {'detail': 'Cet exercice est privé'}
|
assert rr.json() == {'detail': 'Cet exercice est privé'}
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ def test_update(client: TestClient):
|
|||||||
consigne="testconsigne")['id_code']
|
consigne="testconsigne")['id_code']
|
||||||
r = client.put('/exercice/' + id_code, data={"name": "name", "private": True}, files={
|
r = client.put('/exercice/' + id_code, data={"name": "name", "private": True}, files={
|
||||||
'file': ('test2.py', open('tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test2.py', open('tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert 'id_code' in r.json()
|
assert 'id_code' in r.json()
|
||||||
assert r.json() == {'name': "name", 'consigne': "testconsigne", 'private': True, 'id_code': id_code, 'author': {'username': 'lilian'}, 'original': None, 'tags': [], 'exo_source': 'test2.py', 'supports': {
|
assert r.json() == {'name': "name", 'consigne': "testconsigne", 'private': True, 'id_code': id_code, 'author': {'username': 'lilian'}, 'original': None, 'tags': [], 'exo_source': 'test2.py', 'supports': {
|
||||||
@ -149,7 +150,7 @@ def test_update_no_file(client: TestClient):
|
|||||||
id_code = test_create(client, user={'token': token, 'username': "lilian"},
|
id_code = test_create(client, user={'token': token, 'username': "lilian"},
|
||||||
consigne="testconsigne")['id_code']
|
consigne="testconsigne")['id_code']
|
||||||
r = client.put('/exercice/' + id_code, data={"name": "name", "private": True}, headers={"Authorization": "Bearer " + token})
|
r = client.put('/exercice/' + id_code, data={"name": "name", "private": True}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert 'id_code' in r.json()
|
assert 'id_code' in r.json()
|
||||||
assert r.json() == {'name': "name", 'consigne': "testconsigne", 'private': True, 'id_code': id_code, 'author': {'username': 'lilian'}, 'original': None, 'tags': [], 'exo_source': 'test.py', 'supports': {
|
assert r.json() == {'name': "name", 'consigne': "testconsigne", 'private': True, 'id_code': id_code, 'author': {'username': 'lilian'}, 'original': None, 'tags': [], 'exo_source': 'test.py', 'supports': {
|
||||||
@ -163,7 +164,7 @@ def test_update_missing_name(client: TestClient):
|
|||||||
'id_code']
|
'id_code']
|
||||||
r = client.put('/exercice/' + id_code, data={"consigne": "consigne", "private": False}, files={
|
r = client.put('/exercice/' + id_code, data={"consigne": "consigne", "private": False}, files={
|
||||||
'file': ('test2.py', open('tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test2.py', open('tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert r.json()['detail'] == {'name_error': 'field required'}
|
assert r.json()['detail'] == {'name_error': 'field required'}
|
||||||
|
|
||||||
@ -174,7 +175,7 @@ def test_update_missing_main(client: TestClient):
|
|||||||
'id_code']
|
'id_code']
|
||||||
r = client.put('/exercice/' + id_code, data={"consigne": "consigne", "private": False}, files={
|
r = client.put('/exercice/' + id_code, data={"consigne": "consigne", "private": False}, files={
|
||||||
'file': ('test2.py', open('tests/testing_exo_source/exo_source_missing_main.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test2.py', open('tests/testing_exo_source/exo_source_missing_main.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert r.json()['detail'] == {
|
assert r.json()['detail'] == {
|
||||||
'exo_source_error': "Fonction 'main' introuvable"}
|
'exo_source_error': "Fonction 'main' introuvable"}
|
||||||
@ -186,7 +187,7 @@ def test_update_invalid(client: TestClient):
|
|||||||
'id_code']
|
'id_code']
|
||||||
r = client.put('/exercice/' + id_code, data={"consigne": "consigne", "private": False}, files={
|
r = client.put('/exercice/' + id_code, data={"consigne": "consigne", "private": False}, files={
|
||||||
'file': ('test2.py', open('tests/testing_exo_source/exo_source_invalid.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test2.py', open('tests/testing_exo_source/exo_source_invalid.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert r.json()['detail'] == {
|
assert r.json()['detail'] == {
|
||||||
'exo_source_error': "Exercice non valide (compatible avec aucun support)"}
|
'exo_source_error': "Exercice non valide (compatible avec aucun support)"}
|
||||||
@ -199,7 +200,7 @@ def test_update_too_long(client: TestClient):
|
|||||||
'id_code']
|
'id_code']
|
||||||
r = client.put('/exercice/' + id_code, data={'name': 'e'*51, "consigne": "e"*201, "private": False}, files={
|
r = client.put('/exercice/' + id_code, data={'name': 'e'*51, "consigne": "e"*201, "private": False}, files={
|
||||||
'file': ('test2.py', open('tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
'file': ('test2.py', open('tests/testing_exo_source/exo_source.py', 'rb'))}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert r.json()['detail'] == {'name_error': 'ensure this value has at most 50 characters',
|
assert r.json()['detail'] == {'name_error': 'ensure this value has at most 50 characters',
|
||||||
'consigne_error': 'ensure this value has at most 200 characters'}
|
'consigne_error': 'ensure this value has at most 200 characters'}
|
||||||
@ -211,7 +212,7 @@ def test_delete(client: TestClient):
|
|||||||
'id_code']
|
'id_code']
|
||||||
r = client.delete('/exercice/' + id_code,
|
r = client.delete('/exercice/' + id_code,
|
||||||
headers={'Authorization': 'Bearer ' + token})
|
headers={'Authorization': 'Bearer ' + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
assert r.json()['detail'] == 'Exercice supprimé avec succès'
|
assert r.json()['detail'] == 'Exercice supprimé avec succès'
|
||||||
|
|
||||||
@ -220,7 +221,7 @@ def test_delete_not_found(client: TestClient):
|
|||||||
token = test_register(client, username="lilian")['access']
|
token = test_register(client, username="lilian")['access']
|
||||||
r = client.delete('/exercice/' + "test",
|
r = client.delete('/exercice/' + "test",
|
||||||
headers={'Authorization': 'Bearer ' + token})
|
headers={'Authorization': 'Bearer ' + token})
|
||||||
print(r.json())
|
|
||||||
assert r.status_code == 404
|
assert r.status_code == 404
|
||||||
assert r.json()['detail'] == 'Exercice introuvable'
|
assert r.json()['detail'] == 'Exercice introuvable'
|
||||||
|
|
||||||
@ -246,7 +247,7 @@ def test_add_tags(client: TestClient, name='name', tags: List[Tags] = [{'label':
|
|||||||
id_code = exo['id_code']
|
id_code = exo['id_code']
|
||||||
r = client.post(f'/exercice/{id_code}/tags', json=tags,
|
r = client.post(f'/exercice/{id_code}/tags', json=tags,
|
||||||
headers={'Authorization': 'Bearer ' + token})
|
headers={'Authorization': 'Bearer ' + token})
|
||||||
print("DATA", tags, "\n\n",r.json())
|
|
||||||
data = r.json()
|
data = r.json()
|
||||||
labels = [l['label'] for l in tags]
|
labels = [l['label'] for l in tags]
|
||||||
assert r.status_code == 200
|
assert r.status_code == 200
|
||||||
@ -261,7 +262,7 @@ def test_add_tags_invalid_color(client: TestClient):
|
|||||||
id_code = exo['id_code']
|
id_code = exo['id_code']
|
||||||
r = client.post(f'/exercice/{id_code}/tags', json=[
|
r = client.post(f'/exercice/{id_code}/tags', json=[
|
||||||
{'label': "name", 'color': "color", 'id_code': "id_code"}], headers={'Authorization': 'Bearer ' + token})
|
{'label': "name", 'color': "color", 'id_code': "id_code"}], headers={'Authorization': 'Bearer ' + token})
|
||||||
print(r.json())
|
|
||||||
data = r.json()
|
data = r.json()
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert data['detail'] == {
|
assert data['detail'] == {
|
||||||
@ -274,7 +275,7 @@ def test_add_tags_too_long(client: TestClient):
|
|||||||
id_code = exo['id_code']
|
id_code = exo['id_code']
|
||||||
r = client.post(f'/exercice/{id_code}/tags', json=[
|
r = client.post(f'/exercice/{id_code}/tags', json=[
|
||||||
{'label': "n"*21, 'color': "#ff0000", 'id_code': "id_code"}], headers={'Authorization': 'Bearer ' + token})
|
{'label': "n"*21, 'color': "#ff0000", 'id_code': "id_code"}], headers={'Authorization': 'Bearer ' + token})
|
||||||
print(r.json())
|
|
||||||
data = r.json()
|
data = r.json()
|
||||||
assert r.status_code == 422
|
assert r.status_code == 422
|
||||||
assert data['detail'] == {
|
assert data['detail'] == {
|
||||||
@ -288,7 +289,7 @@ def test_remove_tag(client: TestClient):
|
|||||||
tag_id = exo["tags"][0]["id_code"]
|
tag_id = exo["tags"][0]["id_code"]
|
||||||
r = client.delete(f'/exercice/{id_code}/tags/{tag_id}',
|
r = client.delete(f'/exercice/{id_code}/tags/{tag_id}',
|
||||||
headers={'Authorization': 'Bearer ' + token})
|
headers={'Authorization': 'Bearer ' + token})
|
||||||
print(r.json())
|
|
||||||
assert r.json() == {
|
assert r.json() == {
|
||||||
**exo['exo'], 'tags': exo['tags'][1:]}
|
**exo['exo'], 'tags': exo['tags'][1:]}
|
||||||
|
|
||||||
@ -300,7 +301,7 @@ def test_remove_tag_not_found(client: TestClient):
|
|||||||
tag_id = "none"
|
tag_id = "none"
|
||||||
r = client.delete(f'/exercice/{id_code}/tags/{tag_id}',
|
r = client.delete(f'/exercice/{id_code}/tags/{tag_id}',
|
||||||
headers={'Authorization': 'Bearer ' + token})
|
headers={'Authorization': 'Bearer ' + token})
|
||||||
print(r.json())
|
|
||||||
assert r.json()['detail'] == 'Tag introuvable'
|
assert r.json()['detail'] == 'Tag introuvable'
|
||||||
|
|
||||||
|
|
||||||
@ -311,7 +312,7 @@ def test_remove_tag_exo_not_found(client: TestClient):
|
|||||||
id_code = "tets"
|
id_code = "tets"
|
||||||
r = client.delete(f'/exercice/{id_code}/tags/{tag_id}',
|
r = client.delete(f'/exercice/{id_code}/tags/{tag_id}',
|
||||||
headers={'Authorization': 'Bearer ' + token})
|
headers={'Authorization': 'Bearer ' + token})
|
||||||
print(r.json())
|
|
||||||
assert r.json()['detail'] == 'Exercice introuvable'
|
assert r.json()['detail'] == 'Exercice introuvable'
|
||||||
|
|
||||||
|
|
||||||
@ -323,7 +324,7 @@ def test_remove_tag_not_owner(client: TestClient):
|
|||||||
tag_id = exo['tags'][0]['id_code']
|
tag_id = exo['tags'][0]['id_code']
|
||||||
r = client.delete(f'/exercice/{id_code}/tags/{tag_id}',
|
r = client.delete(f'/exercice/{id_code}/tags/{tag_id}',
|
||||||
headers={'Authorization': 'Bearer ' + token2})
|
headers={'Authorization': 'Bearer ' + token2})
|
||||||
print(r.json())
|
|
||||||
assert r.json()['detail'] == "Vous n'êtes pas le propriétaire du tag"
|
assert r.json()['detail'] == "Vous n'êtes pas le propriétaire du tag"
|
||||||
|
|
||||||
|
|
||||||
@ -333,8 +334,8 @@ def test_exo_exo_source(client: TestClient):
|
|||||||
id_code = exo['id_code']
|
id_code = exo['id_code']
|
||||||
r = client.get(f"/exercice/{id_code}/exo_source",
|
r = client.get(f"/exercice/{id_code}/exo_source",
|
||||||
headers={'Authorization': 'Bearer ' + token})
|
headers={'Authorization': 'Bearer ' + token})
|
||||||
print(r.text)
|
|
||||||
print(r.headers)
|
|
||||||
assert r.text == open('tests/testing_exo_source/exo_source.py', 'r').read()
|
assert r.text == open('tests/testing_exo_source/exo_source.py', 'r').read()
|
||||||
assert r.headers['content-disposition'].split('filename=')[-1] == 'test.py'
|
assert r.headers['content-disposition'].split('filename=')[-1] == 'test.py'
|
||||||
|
|
||||||
@ -350,7 +351,7 @@ def test_get_users_exos(client: TestClient):
|
|||||||
|
|
||||||
r = client.get('/exercices/user',
|
r = client.get('/exercices/user',
|
||||||
headers={'Authorization': 'Bearer ' + token1})
|
headers={'Authorization': 'Bearer ' + token1})
|
||||||
print(r.json())
|
|
||||||
assert r.json()['page'] == 1
|
assert r.json()['page'] == 1
|
||||||
assert r.json()['size'] == 50
|
assert r.json()['size'] == 50
|
||||||
assert r.json()["items"] == [prv]
|
assert r.json()["items"] == [prv]
|
||||||
@ -387,7 +388,7 @@ def test_get_users_exos_page(client: TestClient):
|
|||||||
|
|
||||||
r = client.get('/exercices/user',
|
r = client.get('/exercices/user',
|
||||||
headers={'Authorization': 'Bearer ' + token1}, params={"page": 2, "size": 10})
|
headers={'Authorization': 'Bearer ' + token1}, params={"page": 2, "size": 10})
|
||||||
print(r.json())
|
|
||||||
assert r.json()['page'] == 2
|
assert r.json()['page'] == 2
|
||||||
assert r.json()['size'] == 10
|
assert r.json()['size'] == 10
|
||||||
assert r.json()["items"] == [prv11, prv12]
|
assert r.json()["items"] == [prv11, prv12]
|
||||||
@ -424,7 +425,7 @@ def test_get_users_exos_page_up(client: TestClient):
|
|||||||
|
|
||||||
r = client.get('/exercices/user',
|
r = client.get('/exercices/user',
|
||||||
headers={'Authorization': 'Bearer ' + token1}, params={"page": 2, "size": 10})
|
headers={'Authorization': 'Bearer ' + token1}, params={"page": 2, "size": 10})
|
||||||
print(r.json())
|
|
||||||
assert r.json()['page'] == 2
|
assert r.json()['page'] == 2
|
||||||
assert r.json()['size'] == 10
|
assert r.json()['size'] == 10
|
||||||
assert r.json()["items"] == []
|
assert r.json()["items"] == []
|
||||||
@ -451,7 +452,7 @@ def test_get_user_with_search(client: TestClient):
|
|||||||
|
|
||||||
r = client.get('/exercices/user', params={"search": "test"},
|
r = client.get('/exercices/user', params={"search": "test"},
|
||||||
headers={'Authorization': 'Bearer ' + token1})
|
headers={'Authorization': 'Bearer ' + token1})
|
||||||
print(r.json())
|
|
||||||
assert r.json()['items'] == [exo1, exo2]
|
assert r.json()['items'] == [exo1, exo2]
|
||||||
|
|
||||||
|
|
||||||
@ -475,7 +476,7 @@ def test_get_user_with_search(client: TestClient):
|
|||||||
|
|
||||||
r = client.get('/exercices/user', params={"search": "test"},
|
r = client.get('/exercices/user', params={"search": "test"},
|
||||||
headers={'Authorization': 'Bearer ' + token1})
|
headers={'Authorization': 'Bearer ' + token1})
|
||||||
print(r.json())
|
|
||||||
assert r.json()['items'] == [exo1, exo2]
|
assert r.json()['items'] == [exo1, exo2]
|
||||||
|
|
||||||
|
|
||||||
@ -507,7 +508,7 @@ def test_get_user_with_tags(client: TestClient):
|
|||||||
tags3 = exo3['tags']
|
tags3 = exo3['tags']
|
||||||
r = client.get('/exercices/user', params={'tags': [*[t['id_code'] for t in tags2], 'notexisting']},
|
r = client.get('/exercices/user', params={'tags': [*[t['id_code'] for t in tags2], 'notexisting']},
|
||||||
headers={'Authorization': 'Bearer ' + token1})
|
headers={'Authorization': 'Bearer ' + token1})
|
||||||
print("DATA", r.json())
|
|
||||||
assert r.json()['items'] == [exo2['exo'], exo3['exo']]
|
assert r.json()['items'] == [exo2['exo'], exo3['exo']]
|
||||||
|
|
||||||
|
|
||||||
@ -536,7 +537,7 @@ def test_get_user_with_tags_and_search(client: TestClient):
|
|||||||
tags3 = exo3['tags']
|
tags3 = exo3['tags']
|
||||||
r = client.get('/exercices/user', params={"search": "yes", 'tags': [t['id_code'] for t in tags2]},
|
r = client.get('/exercices/user', params={"search": "yes", 'tags': [t['id_code'] for t in tags2]},
|
||||||
headers={'Authorization': 'Bearer ' + token1})
|
headers={'Authorization': 'Bearer ' + token1})
|
||||||
print(r.json())
|
|
||||||
assert r.json()['items'] == [exo3['exo']]
|
assert r.json()['items'] == [exo3['exo']]
|
||||||
|
|
||||||
|
|
||||||
@ -553,7 +554,7 @@ def test_get_public_auth(client: TestClient):
|
|||||||
|
|
||||||
r = client.get('/exercices/public',
|
r = client.get('/exercices/public',
|
||||||
headers={'Authorization': 'Bearer ' + token2})
|
headers={'Authorization': 'Bearer ' + token2})
|
||||||
print(r.json())
|
|
||||||
assert r.json()['items'] == [{**public2, 'is_author': False}]
|
assert r.json()['items'] == [{**public2, 'is_author': False}]
|
||||||
|
|
||||||
|
|
||||||
@ -573,7 +574,7 @@ def test_get_public_auth_with_search(client: TestClient):
|
|||||||
|
|
||||||
r = client.get('/exercices/public',
|
r = client.get('/exercices/public',
|
||||||
params={'search': "yes"}, headers={'Authorization': 'Bearer ' + token2})
|
params={'search': "yes"}, headers={'Authorization': 'Bearer ' + token2})
|
||||||
print(r.json())
|
|
||||||
assert r.json()['items'] == [{**public2, 'is_author': False}]
|
assert r.json()['items'] == [{**public2, 'is_author': False}]
|
||||||
|
|
||||||
|
|
||||||
@ -589,7 +590,7 @@ def test_get_public_no_auth(client: TestClient):
|
|||||||
client, user={'token': token1, 'username': "lilian"})
|
client, user={'token': token1, 'username': "lilian"})
|
||||||
|
|
||||||
r = client.get('/exercices/public')
|
r = client.get('/exercices/public')
|
||||||
print(r.json())
|
|
||||||
assert r.json()['items'] == [{**public1, 'is_author': False},
|
assert r.json()['items'] == [{**public1, 'is_author': False},
|
||||||
{**public2, 'is_author': False}]
|
{**public2, 'is_author': False}]
|
||||||
|
|
||||||
@ -618,7 +619,7 @@ def test_get_exo_auth(client: TestClient):
|
|||||||
|
|
||||||
r = client.get('/exercice/' + exo['exo']['id_code'],
|
r = client.get('/exercice/' + exo['exo']['id_code'],
|
||||||
headers={'Authorization': 'Bearer ' + token2})
|
headers={'Authorization': 'Bearer ' + token2})
|
||||||
print(r.json(), exo)
|
|
||||||
assert r.json() == {**exo['exo'], "tags": [], 'is_author': False}
|
assert r.json() == {**exo['exo'], "tags": [], 'is_author': False}
|
||||||
|
|
||||||
|
|
||||||
@ -632,7 +633,7 @@ def test_get_exo_auth_with_tags(client: TestClient):
|
|||||||
r = client.get('/exercice/' + exo['exo']['id_code'],
|
r = client.get('/exercice/' + exo['exo']['id_code'],
|
||||||
headers={'Authorization': 'Bearer ' + token})
|
headers={'Authorization': 'Bearer ' + token})
|
||||||
|
|
||||||
print(r.json(), exo)
|
|
||||||
assert r.json() == {**exo['exo']}
|
assert r.json() == {**exo['exo']}
|
||||||
|
|
||||||
|
|
||||||
@ -657,7 +658,7 @@ def test_get_tags(client: TestClient):
|
|||||||
tags2 = exo2['tags']
|
tags2 = exo2['tags']
|
||||||
|
|
||||||
r = client.get('/tags', headers={'Authorization': 'Bearer ' + token2})
|
r = client.get('/tags', headers={'Authorization': 'Bearer ' + token2})
|
||||||
print(r.json())
|
|
||||||
assert r.json() == tags2
|
assert r.json() == tags2
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from tests.test_exos import test_create
|
|||||||
def test_create_room_no_auth(client: TestClient, public=False):
|
def test_create_room_no_auth(client: TestClient, public=False):
|
||||||
r = client.post('/room', json={"name": "test_room",
|
r = client.post('/room', json={"name": "test_room",
|
||||||
"public": public}, params={'username': "lilian"})
|
"public": public}, params={'username': "lilian"})
|
||||||
print(r.json())
|
|
||||||
assert "room" in r.json()
|
assert "room" in r.json()
|
||||||
assert "member" in r.json()
|
assert "member" in r.json()
|
||||||
assert r.json()['member'] is not None
|
assert r.json()['member'] is not None
|
||||||
@ -18,7 +18,7 @@ def test_create_room_no_auth(client: TestClient, public=False):
|
|||||||
def test_create_room_no_auth_invalid(client: TestClient):
|
def test_create_room_no_auth_invalid(client: TestClient):
|
||||||
r = client.post('/room', json={"name": "test_room" * 21,
|
r = client.post('/room', json={"name": "test_room" * 21,
|
||||||
"public": False}, params={'username': "lilian" * 21})
|
"public": False}, params={'username': "lilian" * 21})
|
||||||
print(r.json())
|
|
||||||
assert r.json() == {'detail': {'username_error': 'ensure this value has at most 20 characters',
|
assert r.json() == {'detail': {'username_error': 'ensure this value has at most 20 characters',
|
||||||
'name_error': 'ensure this value has at most 20 characters'}}
|
'name_error': 'ensure this value has at most 20 characters'}}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ def test_create_room_auth(client: TestClient, token=None, public=False):
|
|||||||
token = test_register(client=client)['access']
|
token = test_register(client=client)['access']
|
||||||
r = client.post('/room', json={"name": "test_room",
|
r = client.post('/room', json={"name": "test_room",
|
||||||
"public": public}, headers={"Authorization": "Bearer " + token})
|
"public": public}, headers={"Authorization": "Bearer " + token})
|
||||||
print(r.json())
|
|
||||||
assert "room" in r.json()
|
assert "room" in r.json()
|
||||||
assert "member" in r.json()
|
assert "member" in r.json()
|
||||||
assert r.json()['member'] == None
|
assert r.json()['member'] == None
|
||||||
@ -81,7 +81,7 @@ def test_login_no_auth_not_in_room(client: TestClient):
|
|||||||
ws.send_json({"type": "login", "data": {
|
ws.send_json({"type": "login", "data": {
|
||||||
"reconnect_code": "lol"}})
|
"reconnect_code": "lol"}})
|
||||||
data = ws.receive_json()
|
data = ws.receive_json()
|
||||||
print(data)
|
|
||||||
assert data == {'type': "error", "data": {"code": 401,
|
assert data == {'type': "error", "data": {"code": 401,
|
||||||
"msg": "Utilisateur introuvable dans cette salle"}}
|
"msg": "Utilisateur introuvable dans cette salle"}}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ def test_login_auth(client: TestClient):
|
|||||||
with client.websocket_connect(f"/ws/room/" + room['room']) as ws:
|
with client.websocket_connect(f"/ws/room/" + room['room']) as ws:
|
||||||
ws.send_json({"type": "login", "data": {"token": token}})
|
ws.send_json({"type": "login", "data": {"token": token}})
|
||||||
data = ws.receive_json()
|
data = ws.receive_json()
|
||||||
print(data)
|
|
||||||
assert "id_code" in data["data"]['member']
|
assert "id_code" in data["data"]['member']
|
||||||
assert data == {'type': "loggedIn", "data": {"member": {**data["data"]['member'],
|
assert data == {'type': "loggedIn", "data": {"member": {**data["data"]['member'],
|
||||||
"username": "lilian", "isAdmin": True, "isUser": True,
|
"username": "lilian", "isAdmin": True, "isUser": True,
|
||||||
@ -107,7 +107,7 @@ def test_login_auth_not_in_room(client: TestClient):
|
|||||||
with client.websocket_connect(f"/ws/room/" + room['room']) as ws:
|
with client.websocket_connect(f"/ws/room/" + room['room']) as ws:
|
||||||
ws.send_json({"type": "login", "data": {"token": token}})
|
ws.send_json({"type": "login", "data": {"token": token}})
|
||||||
data = ws.receive_json()
|
data = ws.receive_json()
|
||||||
print(data)
|
|
||||||
assert data == {'type': "error", "data": {"code": 401,
|
assert data == {'type': "error", "data": {"code": 401,
|
||||||
"msg": "Utilisateur introuvable dans cette salle"}}
|
"msg": "Utilisateur introuvable dans cette salle"}}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ def test_join_auth(client: TestClient):
|
|||||||
assert mdata == {"type": "accepted", "data": {"member": {
|
assert mdata == {"type": "accepted", "data": {"member": {
|
||||||
"username": "lilian2", "isUser": True, "isAdmin": False, "reconnect_code": "",
|
"username": "lilian2", "isUser": True, "isAdmin": False, "reconnect_code": "",
|
||||||
"id_code": mdata['data']["member"]["id_code"], "clientId": "", "online": True}}}
|
"id_code": mdata['data']["member"]["id_code"], "clientId": "", "online": True}}}
|
||||||
print("MDATABUS", mdata)
|
|
||||||
adata = admin.receive_json()
|
adata = admin.receive_json()
|
||||||
|
|
||||||
assert adata == {'type': "joined", 'data': {
|
assert adata == {'type': "joined", 'data': {
|
||||||
@ -601,7 +601,7 @@ def test_create_parcours_no_auth(client: TestClient):
|
|||||||
{"exercice_id": exo2['id_code'], "quantity": 5},
|
{"exercice_id": exo2['id_code'], "quantity": 5},
|
||||||
{"exercice_id": exo3['id_code'],
|
{"exercice_id": exo3['id_code'],
|
||||||
"quantity": 12}]})
|
"quantity": 12}]})
|
||||||
print('resonse', r.json(), exo3)
|
|
||||||
assert r.json() == {"id_code": r.json()['id_code'], "memberRank": None, "name": "test_parcours", "pb": None,
|
assert r.json() == {"id_code": r.json()['id_code'], "memberRank": None, "name": "test_parcours", "pb": None,
|
||||||
"rank": None, "ranking": [], "tops": [], "validated": False, "challenges": {},
|
"rank": None, "ranking": [], "tops": [], "validated": False, "challenges": {},
|
||||||
"name": "test_parcours", "time": 10 * 60,
|
"name": "test_parcours", "time": 10 * 60,
|
||||||
@ -925,7 +925,7 @@ def test_corrige_auth(client: TestClient):
|
|||||||
r = client.post(f'/room/{room["room"]}/parcours', headers={"Authorization": "Bearer " + token},
|
r = client.post(f'/room/{room["room"]}/parcours', headers={"Authorization": "Bearer " + token},
|
||||||
json={"name": "test_parcours", "time": 10 * 60, "max_mistakes": 10, "exercices": [
|
json={"name": "test_parcours", "time": 10 * 60, "max_mistakes": 10, "exercices": [
|
||||||
{"exercice_id": exo1['id_code'], "quantity": 3}]})
|
{"exercice_id": exo1['id_code'], "quantity": 3}]})
|
||||||
print(r.json())
|
|
||||||
parcours_id = r.json()['id_code']
|
parcours_id = r.json()['id_code']
|
||||||
memberws.receive_json()
|
memberws.receive_json()
|
||||||
admin.receive_json() # new parcours
|
admin.receive_json() # new parcours
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
afterNavigate(() => {
|
afterNavigate(() => {
|
||||||
open = false;
|
open = false;
|
||||||
});
|
});
|
||||||
$: console.log("USERNAME", $username);
|
$:
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav data-sveltekit-preload-data="hover" class:open>
|
<nav data-sveltekit-preload-data="hover" class:open>
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
cancel()
|
cancel()
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
loading=false
|
loading=false
|
||||||
console.log(e)
|
|
||||||
error('Erreur', 'Une erreur est survenue lors de la modification de l\'exercice')
|
error('Erreur', 'Une erreur est survenue lors de la modification de l\'exercice')
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
tags: [...selected.map((t) => t.id_code)]
|
tags: [...selected.map((t) => t.id_code)]
|
||||||
})
|
})
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
console.log("R", r);
|
|
||||||
if (activePage > r.totalPage && r.total != 0 && r.totalPage != 0) {
|
if (activePage > r.totalPage && r.total != 0 && r.totalPage != 0) {
|
||||||
activePage = r.totalPage;
|
activePage = r.totalPage;
|
||||||
//$p.url.searchParams.set('page', String(activePage));
|
//$p.url.searchParams.set('page', String(activePage));
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
export let label: string;
|
export let label: string;
|
||||||
export let color: string;
|
export let color: string;
|
||||||
console.log(color)
|
|
||||||
export let remove: Function | null = null;
|
export let remove: Function | null = null;
|
||||||
let removed = false;
|
let removed = false;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$: console.log('ID', id, invi);
|
$:
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="tags" bind:this={tg} {id}>
|
<div class="tags" bind:this={tg} {id}>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
};
|
};
|
||||||
let test: HTMLInputElement;
|
let test: HTMLInputElement;
|
||||||
export const focus = () => {
|
export const focus = () => {
|
||||||
console.log('FOCUS', test)
|
|
||||||
test.focus();
|
test.focus();
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
//export let isMultiple = false;
|
//export let isMultiple = false;
|
||||||
|
|
||||||
const color = chroma("rgb(255,0,0)");
|
const color = chroma("rgb(255,0,0)");
|
||||||
console.log(color.rgb(), color);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- you need to use itemActions and pass given events -->
|
<!-- you need to use itemActions and pass given events -->
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
let show = type != 'password';
|
let show = type != 'password';
|
||||||
const id = Math.random().toString(36).substr(2, 9);
|
const id = Math.random().toString(36).substr(2, 9);
|
||||||
const toggle = () => {
|
const toggle = () => {
|
||||||
console.log('OOGLE ')
|
|
||||||
const element = document.getElementById(id) as HTMLInputElement;
|
const element = document.getElementById(id) as HTMLInputElement;
|
||||||
if (element === null) return;
|
if (element === null) return;
|
||||||
element.type = show === true ? 'password' : 'text';
|
element.type = show === true ? 'password' : 'text';
|
||||||
|
@ -31,12 +31,12 @@
|
|||||||
}}
|
}}
|
||||||
on:change={
|
on:change={
|
||||||
(s)=>{
|
(s)=>{
|
||||||
console.log('CHANGES', s)
|
|
||||||
selected = s.detail
|
selected = s.detail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
on:createoption={(opt) => {
|
on:createoption={(opt) => {
|
||||||
console.log('NEW OPT', opt);
|
|
||||||
|
|
||||||
selected.push({ ...opt.detail });
|
selected.push({ ...opt.detail });
|
||||||
}}
|
}}
|
||||||
|
@ -186,7 +186,7 @@
|
|||||||
hidden={!$challengeStore.corriged}
|
hidden={!$challengeStore.corriged}
|
||||||
class="primary-btn"
|
class="primary-btn"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
console.log('RETRY CLICKED')
|
|
||||||
challenge($room.id_code, id_code, !$member.isUser ? $member.clientId : null).then((p) => {
|
challenge($room.id_code, id_code, !$member.isUser ? $member.clientId : null).then((p) => {
|
||||||
challengeStore.set({ ...p, corriged: false });
|
challengeStore.set({ ...p, corriged: false });
|
||||||
remaining = null;
|
remaining = null;
|
||||||
|
@ -18,12 +18,12 @@
|
|||||||
let mainDiv: HTMLDivElement;
|
let mainDiv: HTMLDivElement;
|
||||||
|
|
||||||
const toggleFocus = (e: FocusEvent) => {
|
const toggleFocus = (e: FocusEvent) => {
|
||||||
console.log(mainDiv,e.relatedTarget, mainDiv.contains(e.relatedTarget as Node))
|
|
||||||
if (hidden == true && !mainDiv.contains(e.relatedTarget as Node)) {
|
if (hidden == true && !mainDiv.contains(e.relatedTarget as Node)) {
|
||||||
hidden = false;
|
hidden = false;
|
||||||
console.log("PASEED");
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
console.log("HOPIDOP");
|
|
||||||
close = true;
|
close = true;
|
||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@
|
|||||||
!$isAuth ? $member?.clientId : null
|
!$isAuth ? $member?.clientId : null
|
||||||
)
|
)
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
console.log(r);
|
|
||||||
parcours.set(r);
|
parcours.set(r);
|
||||||
$page.url.searchParams.delete('edit');
|
$page.url.searchParams.delete('edit');
|
||||||
|
|
||||||
@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
})
|
})
|
||||||
.catch((r) => {
|
.catch((r) => {
|
||||||
console.log(r);
|
|
||||||
error('Echec lors de la modification du parcours', `Raison: ${r.detail}`);
|
error('Echec lors de la modification du parcours', `Raison: ${r.detail}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@
|
|||||||
goto(`?${$page.url.searchParams.toString()}`);
|
goto(`?${$page.url.searchParams.toString()}`);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log('CLICKED');
|
|
||||||
$page.url.searchParams.delete('p');
|
$page.url.searchParams.delete('p');
|
||||||
goto(`?${$page.url.searchParams.toString()}`);
|
goto(`?${$page.url.searchParams.toString()}`);
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
editing = true;
|
editing = true;
|
||||||
name = $room.name;
|
name = $room.name;
|
||||||
r.focus();
|
r.focus();
|
||||||
console.log("OPENED")
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{$room.name}<span on:dblclick|stopPropagation>#{$room.id_code}</span>
|
{$room.name}<span on:dblclick|stopPropagation>#{$room.id_code}</span>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
const member: Writable<Waiting | null> = getContext("member");
|
const member: Writable<Waiting | null> = getContext("member");
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
console.log("MOUNT, $member");
|
|
||||||
if ($member == null || !$member.waiter_id) {
|
if ($member == null || !$member.waiter_id) {
|
||||||
goto("?");
|
goto("?");
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
visible = true;
|
visible = true;
|
||||||
closed = false;
|
closed = false;
|
||||||
component = c;
|
component = c;
|
||||||
console.log('edi', editing, c, p)
|
|
||||||
if (editing) {
|
if (editing) {
|
||||||
console.log('EDITINGF', props)
|
|
||||||
props = { ...props, ...p };
|
props = { ...props, ...p };
|
||||||
console.log(props)
|
|
||||||
} else {
|
} else {
|
||||||
props = p;
|
props = p;
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@
|
|||||||
}
|
}
|
||||||
setContext('modal', { show, close });
|
setContext('modal', { show, close });
|
||||||
function keyPress(e: KeyboardEvent) {
|
function keyPress(e: KeyboardEvent) {
|
||||||
console.log('HOP');
|
|
||||||
if (e.key == 'Escape' && visible == true) {
|
if (e.key == 'Escape' && visible == true) {
|
||||||
visible = false;
|
visible = false;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
| undefined
|
| undefined
|
||||||
) => {
|
) => {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
console.log('PREVIOUS', previous, typeof url == 'number', previous);
|
|
||||||
if (typeof url == 'number' && previous != null) {
|
if (typeof url == 'number' && previous != null) {
|
||||||
const id = Math.abs(url);
|
const id = Math.abs(url);
|
||||||
if (previous.length > id) {
|
if (previous.length > id) {
|
||||||
|
@ -62,7 +62,7 @@ export const getExos = (
|
|||||||
size?: number;
|
size?: number;
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
console.log('SENDINF', data, stringify(data, { arrayFormat: 'brackets' }));
|
|
||||||
return exoInstance({
|
return exoInstance({
|
||||||
url: '/exercices/' + category,
|
url: '/exercices/' + category,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
const { logout, username, isAuth, initialLoading } = getContext("auth");
|
const { logout, username, isAuth, initialLoading } = getContext("auth");
|
||||||
|
|
||||||
$: !$initialLoading && $isAuth && dashBoardRequest().then((res) => {
|
$: !$initialLoading && $isAuth && dashBoardRequest().then((res) => {
|
||||||
console.log(res);
|
|
||||||
user.set(res);
|
user.set(res);
|
||||||
});
|
});
|
||||||
const { show, close } = getContext("modal");
|
const { show, close } = getContext("modal");
|
||||||
@ -59,7 +59,7 @@
|
|||||||
close()
|
close()
|
||||||
success("Sécurité", "Mot de passe mises à jour avec succès")
|
success("Sécurité", "Mot de passe mises à jour avec succès")
|
||||||
}).catch((e)=>{
|
}).catch((e)=>{
|
||||||
console.log('Erreur', e)
|
|
||||||
error("Sécurité","Une erreur est survenue")
|
error("Sécurité","Une erreur est survenue")
|
||||||
})
|
})
|
||||||
}, validate: "Changer mon mot de passe", cancel: close, cancelMsg: "Garder le mot de passe actuel"})
|
}, validate: "Changer mon mot de passe", cancel: close, cancelMsg: "Garder le mot de passe actuel"})
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
AskPseudo,
|
AskPseudo,
|
||||||
{
|
{
|
||||||
validate: (p: string) => {
|
validate: (p: string) => {
|
||||||
console.log("OH", p, p.startsWith("#"));
|
|
||||||
if (p.startsWith("#")) {
|
if (p.startsWith("#")) {
|
||||||
ws.send({ type: "login", data: { reconnect_code: p.replace("#", "") } });
|
ws.send({ type: "login", data: { reconnect_code: p.replace("#", "") } });
|
||||||
} else {
|
} else {
|
||||||
@ -407,7 +407,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
$: onEvent($events[0]);
|
$: onEvent($events[0]);
|
||||||
$: console.log($page.params.slug, $page, $page.params, $page.url.searchParams.get("p"));
|
$:
|
||||||
let fade = false;
|
let fade = false;
|
||||||
|
|
||||||
beforeNavigate((n) => {
|
beforeNavigate((n) => {
|
||||||
@ -424,7 +424,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
afterNavigate((n) => {
|
afterNavigate((n) => {
|
||||||
console.log("AGTER", n);
|
|
||||||
let oldParcoursId =
|
let oldParcoursId =
|
||||||
n.from?.url.searchParams.get("p") ||
|
n.from?.url.searchParams.get("p") ||
|
||||||
n.from?.url.searchParams.get("corr") ||
|
n.from?.url.searchParams.get("corr") ||
|
||||||
@ -448,7 +448,7 @@
|
|||||||
} else */
|
} else */
|
||||||
});
|
});
|
||||||
|
|
||||||
$: console.log("edit", $page.url.searchParams.get("a"));
|
$:
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
|
|
||||||
ws.close(1000);
|
ws.close(1000);
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<button
|
<button
|
||||||
class="primary-btn"
|
class="primary-btn"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
console.log('(NAME)', name)
|
|
||||||
loading = true
|
loading = true
|
||||||
createRoom({ name }, !$isAuth ? pseudo : null).then((r) => {
|
createRoom({ name }, !$isAuth ? pseudo : null).then((r) => {
|
||||||
|
|
||||||
@ -33,7 +33,7 @@
|
|||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
error("Erreur", "Une erreur est survenue lors de la création de la salle")
|
error("Erreur", "Une erreur est survenue lors de la création de la salle")
|
||||||
loading= false
|
loading= false
|
||||||
console.log(e);
|
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
let password = '';
|
let password = '';
|
||||||
|
|
||||||
const { login, isAuth, initialLoading } = getContext('auth');
|
const { login, isAuth, initialLoading } = getContext('auth');
|
||||||
console.log('TEST1', initialLoading, isAuth);
|
|
||||||
$: {
|
$: {
|
||||||
!$initialLoading && !!$isAuth && goto('/dashboard');
|
!$initialLoading && !!$isAuth && goto('/dashboard');
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
loading = true
|
loading = true
|
||||||
register($username.value, $password.value, $confirm.value).then(()=>{loading=false}).catch((r) => {
|
register($username.value, $password.value, $confirm.value).then(()=>{loading=false}).catch((r) => {
|
||||||
loading = false
|
loading = false
|
||||||
console.log('ERREUR', r);
|
|
||||||
|
|
||||||
errors = { ...errors, ...r.data.detail };
|
errors = { ...errors, ...r.data.detail };
|
||||||
});
|
});
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -230,7 +230,7 @@ describe('Participants', () => {
|
|||||||
key: 'ws',
|
key: 'ws',
|
||||||
value: {
|
value: {
|
||||||
send: (t, d) => {
|
send: (t, d) => {
|
||||||
console.log('update', d.public);
|
|
||||||
if (t === 'set_visibility') {
|
if (t === 'set_visibility') {
|
||||||
roomStore.update((r) => {
|
roomStore.update((r) => {
|
||||||
r.public = d.public;
|
r.public = d.public;
|
||||||
@ -456,7 +456,7 @@ describe('Input challenge', () => {
|
|||||||
await fireEvent.click(inputElement);
|
await fireEvent.click(inputElement);
|
||||||
const validToggle = input.getByTestId('valid');
|
const validToggle = input.getByTestId('valid');
|
||||||
const invalid = input.getByTestId('invalid');
|
const invalid = input.getByTestId('invalid');
|
||||||
console.log(invalid);
|
|
||||||
|
|
||||||
await fireEvent.mouseDown(validToggle);
|
await fireEvent.mouseDown(validToggle);
|
||||||
expect(get(valid)).toBeTruthy();
|
expect(get(valid)).toBeTruthy();
|
||||||
@ -768,7 +768,7 @@ describe('Challenges', () => {
|
|||||||
await fireEvent.click(extend);
|
await fireEvent.click(extend);
|
||||||
|
|
||||||
challenges.getByText((t, e) => {
|
challenges.getByText((t, e) => {
|
||||||
console.log('PH', t, e?.textContent);
|
|
||||||
return e.textContent == '6 fautes en 10s';
|
return e.textContent == '6 fautes en 10s';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -808,7 +808,7 @@ describe('Challenges', () => {
|
|||||||
const extendText2 = challenges.getByText('test2');
|
const extendText2 = challenges.getByText('test2');
|
||||||
await fireEvent.click(extendText2);
|
await fireEvent.click(extendText2);
|
||||||
challenges.getByText((t, e) => {
|
challenges.getByText((t, e) => {
|
||||||
console.log('PH', t, e?.textContent);
|
|
||||||
return e.textContent == '10 fautes en 01 : 10s';
|
return e.textContent == '10 fautes en 01 : 10s';
|
||||||
});
|
});
|
||||||
expect(
|
expect(
|
||||||
|
@ -7,7 +7,7 @@ export const errorMsg = (
|
|||||||
},
|
},
|
||||||
name: string
|
name: string
|
||||||
): string[] => {
|
): string[] => {
|
||||||
console.log(form.errors)
|
|
||||||
return [
|
return [
|
||||||
form.hasError(`${name}.required`) && 'Champ requis',
|
form.hasError(`${name}.required`) && 'Champ requis',
|
||||||
form.hasError(`${name}.min`) && 'Trop court',
|
form.hasError(`${name}.min`) && 'Trop court',
|
||||||
@ -22,7 +22,7 @@ export const errorMsg = (
|
|||||||
|
|
||||||
export const checkFile = () => {
|
export const checkFile = () => {
|
||||||
return async (value: Array<File>) => {
|
return async (value: Array<File>) => {
|
||||||
console.log('VALIDATION', value)
|
|
||||||
if (value.length == 0) {
|
if (value.length == 0) {
|
||||||
return { valid:false, name: 'required' };
|
return { valid:false, name: 'required' };
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ export const compareObject = (obj1: object, obj2: object) => {
|
|||||||
const key = keys[i];
|
const key = keys[i];
|
||||||
const v1 = obj1[key as keyof typeof obj1];
|
const v1 = obj1[key as keyof typeof obj1];
|
||||||
const v2 = obj2[key as keyof typeof obj2];
|
const v2 = obj2[key as keyof typeof obj2];
|
||||||
console.log(obj1, obj2, v1, v2, key);
|
|
||||||
if (v1 != undefined && v2 != undefined) {
|
if (v1 != undefined && v2 != undefined) {
|
||||||
if (v1 != v2) {
|
if (v1 != v2) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user