Simone Robutti 44340fde8f
Introduced FastAPI and Postgres support ()
* added poc

* added check for sqlite db

* added events test

* draft docker-compose-test.yml

* improved docker-compose

* added support for postgres migrations

* add documentation

* added some qol to migrations

* added migration generation script

* removed settings.toml

* waiting for postgress in script

* commented script

* added sample web config

* fixed tests

* mock memory db

* reviewed PR
2022-10-14 22:11:27 +02:00

38 lines
1.1 KiB
Python

import logging
import pytest
import urllib3.util
from mobilizon_reshare.web.backend import main
from mobilizon_reshare.web.backend.main import check_database, init_app
def test_check_database_sqlite(caplog):
with caplog.at_level(logging.WARNING):
check_database()
assert caplog.messages == [
"Database is SQLite. This might create issues when running the web application. "
"Please use a PostgreSQL or MariaDB backend."
]
@pytest.mark.asyncio
async def test_check_database_cli(caplog):
with caplog.at_level(logging.WARNING):
await init_app(init_logging=False)
assert caplog.messages == [
"Database is SQLite. This might create issues when running the web application. "
"Please use a PostgreSQL or MariaDB backend."
]
@pytest.mark.asyncio
async def test_check_database_postgres(caplog, monkeypatch):
def get_url():
return urllib3.util.parse_url("postgres://someone@something.it")
monkeypatch.setattr(main, "get_db_url", get_url)
with caplog.at_level(logging.WARNING):
check_database()
assert caplog.messages == []