Bumped coverage

This commit is contained in:
Mawoka
2022-04-30 18:56:56 +02:00
parent 6537258133
commit b8e1e79b4a
3 changed files with 182 additions and 121 deletions
+71 -5
View File
@@ -1,16 +1,35 @@
import pytest
from typing import Generator
from fastapi.testclient import TestClient
from classquiz import app
# from classquiz.socket_server import sio
from classquiz import app as fastapi_app
# from typing import List, Optional
# stdlib imports
# import asyncio
# 3rd party imports
import pytest
# import socketio
# import uvicorn
# FastAPI imports
# from fastapi import FastAPI
PORT = 8000
class ValueStorage:
quiz_id = None
imported_quizzes = [None]
imported_quizzes = []
game_pin = None
game_id = None
example_quiz = {
"public": False,
"public": True,
"title": "Some test question",
"description": "A description",
"questions": [
@@ -37,5 +56,52 @@ test_user_password = "test"
@pytest.fixture(scope="module")
def test_client() -> Generator:
with TestClient(app) as testclient:
with TestClient(fastapi_app) as testclient:
yield testclient
#
# sio.eio.start_service_task = False
#
#
# class UvicornTestServer(uvicorn.Server):
# """Uvicorn test server
#
# Usage:
# @pytest.fixture
# async def start_stop_server():
# server = UvicornTestServer()
# await server.up()
# yield
# await server.down()
# """
#
# def __init__(self, app: FastAPI = fastapi_app, host: str = '127.0.0.1', port: int = PORT):
# """Create a Uvicorn test server
#
# Args:
# app (FastAPI, optional): the FastAPI app. Defaults to main.app.
# host (str, optional): the host ip. Defaults to '127.0.0.1'.
# port (int, optional): the port. Defaults to PORT.
# """
# self._startup_done = asyncio.Event()
# super().__init__(config=uvicorn.Config(app, host=host, port=port))
#
# async def startup(self, sockets: Optional[List] = None) -> None:
# """Override uvicorn startup"""
# await super().startup(sockets=sockets)
# self.config.setup_event_loop()
# self._startup_done.set()
#
# async def up(self) -> None:
# """Start up server asynchronously"""
# self._serve_task = asyncio.create_task(self.serve())
# await self._startup_done.wait()
#
# async def down(self) -> None:
# """Shut down server asynchronously"""
# self.should_exit = True
# await self._serve_task
#
#
#