added events test
This commit is contained in:
parent
a80eca8a01
commit
feee7e7f42
|
@ -272,12 +272,50 @@ test = ["anyio[trio] (>=3.2.1,<4.0.0)", "black (==22.8.0)", "databases[sqlite] (
|
|||
|
||||
[[package]]
|
||||
name = "h11"
|
||||
version = "0.13.0"
|
||||
version = "0.12.0"
|
||||
description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[[package]]
|
||||
name = "httpcore"
|
||||
version = "0.15.0"
|
||||
description = "A minimal low-level HTTP client."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
anyio = ">=3.0.0,<4.0.0"
|
||||
certifi = "*"
|
||||
h11 = ">=0.11,<0.13"
|
||||
sniffio = ">=1.0.0,<2.0.0"
|
||||
|
||||
[package.extras]
|
||||
http2 = ["h2 (>=3,<5)"]
|
||||
socks = ["socksio (>=1.0.0,<2.0.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "httpx"
|
||||
version = "0.23.0"
|
||||
description = "The next generation HTTP client."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
certifi = "*"
|
||||
httpcore = ">=0.15.0,<0.16.0"
|
||||
rfc3986 = {version = ">=1.3,<2", extras = ["idna2008"]}
|
||||
sniffio = "*"
|
||||
|
||||
[package.extras]
|
||||
brotli = ["brotlicffi", "brotli"]
|
||||
cli = ["click (>=8.0.0,<9.0.0)", "rich (>=10,<13)", "pygments (>=2.0.0,<3.0.0)"]
|
||||
http2 = ["h2 (>=3,<5)"]
|
||||
socks = ["socksio (>=1.0.0,<2.0.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "3.3"
|
||||
|
@ -615,6 +653,20 @@ urllib3 = ">=1.25.10"
|
|||
[package.extras]
|
||||
tests = ["coverage (>=3.7.1,<6.0.0)", "pytest-cov", "pytest-localserver", "flake8", "types-mock", "types-requests", "types-six", "pytest (>=4.6,<5.0)", "pytest (>=4.6)", "mypy"]
|
||||
|
||||
[[package]]
|
||||
name = "rfc3986"
|
||||
version = "1.5.0"
|
||||
description = "Validating URI References per RFC 3986"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.dependencies]
|
||||
idna = {version = "*", optional = true, markers = "extra == \"idna2008\""}
|
||||
|
||||
[package.extras]
|
||||
idna2008 = ["idna"]
|
||||
|
||||
[[package]]
|
||||
name = "six"
|
||||
version = "1.16.0"
|
||||
|
@ -942,7 +994,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-
|
|||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.9"
|
||||
content-hash = "199b3be9e7cf5adb6ddff51200181f03c9386bcd92dc09bf2c899bb6baa090ce"
|
||||
content-hash = "56fecab376d8a94ff6dd64f853128388f458001b6f4eb63dddc3fd4bb2773df1"
|
||||
|
||||
[metadata.files]
|
||||
aerich = []
|
||||
|
@ -992,7 +1044,12 @@ docutils = []
|
|||
dynaconf = []
|
||||
facebook-sdk = []
|
||||
fastapi = []
|
||||
h11 = []
|
||||
h11 = [
|
||||
{file = "h11-0.12.0-py3-none-any.whl", hash = "sha256:36a3cb8c0a032f56e2da7084577878a035d3b61d104230d4bd49c0c6b555a9c6"},
|
||||
{file = "h11-0.12.0.tar.gz", hash = "sha256:47222cb6067e4a307d535814917cd98fd0a57b6788ce715755fa2b6c28b56042"},
|
||||
]
|
||||
httpcore = []
|
||||
httpx = []
|
||||
idna = [
|
||||
{file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"},
|
||||
{file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"},
|
||||
|
@ -1060,6 +1117,10 @@ responses = [
|
|||
{file = "responses-0.13.4-py2.py3-none-any.whl", hash = "sha256:d8d0f655710c46fd3513b9202a7f0dcedd02ca0f8cf4976f27fa8ab5b81e656d"},
|
||||
{file = "responses-0.13.4.tar.gz", hash = "sha256:9476775d856d3c24ae660bbebe29fb6d789d4ad16acd723efbfb6ee20990b899"},
|
||||
]
|
||||
rfc3986 = [
|
||||
{file = "rfc3986-1.5.0-py2.py3-none-any.whl", hash = "sha256:a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97"},
|
||||
{file = "rfc3986-1.5.0.tar.gz", hash = "sha256:270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835"},
|
||||
]
|
||||
six = [
|
||||
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
|
||||
{file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"},
|
||||
|
|
|
@ -37,6 +37,7 @@ Sphinx = "~4.4"
|
|||
sphinxcontrib-napoleon = "~0.7"
|
||||
sphinx-material = "~0.0"
|
||||
sphinx-autodoc-typehints = "~1.17"
|
||||
httpx = "^0.23.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import asyncio
|
||||
import importlib.resources
|
||||
import os
|
||||
import time
|
||||
from collections import UserList
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import time
|
||||
from typing import Union
|
||||
from uuid import UUID
|
||||
|
||||
|
@ -130,7 +129,7 @@ async def stored_event(event) -> Event:
|
|||
|
||||
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
def initialize_db_tests(request) -> None:
|
||||
async def initialize_db_tests(request) -> None:
|
||||
config = {
|
||||
"connections": {
|
||||
"default": os.environ.get("TORTOISE_TEST_DB", "sqlite://:memory:")
|
||||
|
@ -161,10 +160,9 @@ def initialize_db_tests(request) -> None:
|
|||
await Tortoise.init(config, _create_db=True)
|
||||
await Tortoise.generate_schemas(safe=False)
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(_init_db())
|
||||
|
||||
request.addfinalizer(lambda: loop.run_until_complete(Tortoise._drop_databases()))
|
||||
await _init_db()
|
||||
yield
|
||||
await Tortoise._drop_databases()
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
from mobilizon_reshare.web.backend.main import app, register_endpoints
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def anyio_backend():
|
||||
return "asyncio"
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
async def client():
|
||||
register_endpoints(app)
|
||||
async with AsyncClient(app=app, base_url="http://test") as client:
|
||||
yield client
|
|
@ -0,0 +1,16 @@
|
|||
import json
|
||||
|
||||
import pytest
|
||||
from httpx import AsyncClient
|
||||
|
||||
from mobilizon_reshare.web.backend.main import event_pydantic
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_events(client: AsyncClient, event_model_generator):
|
||||
event = event_model_generator()
|
||||
await event.save()
|
||||
|
||||
response = await client.get("/events")
|
||||
assert response.status_code == 200
|
||||
assert response.json()[0] == [json.loads(event_pydantic.from_orm(event).json())][0]
|
Loading…
Reference in New Issue