Advertisement
mrmamongo

test_bots.py

Jun 8th, 2023
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. import unittest
  2.  
  3. import pytest
  4. from fastapi.testclient import TestClient
  5.  
  6. from src.routers.bots.models import BotCreate, BotRead
  7.  
  8.  
  9. @pytest.mark.asyncio
  10. async def test_get_bots_empty(event_loop, session_override, mock_client: TestClient):
  11.     bots = [
  12.         BotCreate(
  13.             bot_token="first", name="first", alias="first_bot", description="first_bot"
  14.         ),
  15.         BotCreate(
  16.             bot_token="second",
  17.             name="second",
  18.             alias="second_bot",
  19.             description="second_bot",
  20.         ),
  21.     ]
  22.  
  23.     for bot in bots:
  24.         response = mock_client.post("/bot", data=bot.json())
  25.         print(response.json())
  26.         assert response.status_code == 200
  27.  
  28.     response = mock_client.get("/bot")
  29.     print(response.text)
  30.     assert response.json() == [BotRead.parse_obj(bot.dict()).dict() for bot in bots]
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement