feat: added support for mongodb

This commit is contained in:
2024-11-27 10:46:41 +01:00
parent 8160d9a383
commit 4a45119549
25 changed files with 923 additions and 348 deletions

View File

@ -3,11 +3,11 @@ import os
from typing import Iterator
import pytest
from bec_atlas.main import AtlasApp
from bec_atlas.utils.setup_database import setup_database
from fastapi.testclient import TestClient
from pytest_docker.plugin import DockerComposeExecutor, Services
from bec_atlas.main import AtlasApp
def pytest_addoption(parser):
parser.addoption(
@ -101,42 +101,39 @@ def docker_services(
yield docker_service
@pytest.fixture(scope="session")
def scylla_container(docker_ip, docker_services):
host = docker_ip
if os.path.exists("/.dockerenv"):
# if we are running in the CI, scylla was started as 'scylla' service
host = "scylla"
if docker_services is None:
port = 9042
else:
port = docker_services.port_for("scylla", 9042)
setup_database(host=host, port=port)
return host, port
@pytest.fixture(scope="session")
def redis_container(docker_ip, docker_services):
host = docker_ip
if os.path.exists("/.dockerenv"):
# if we are running in the CI, scylla was started as 'scylla' service
host = "redis"
if docker_services is None:
port = 6380
else:
port = docker_services.port_for("redis", 6379)
return host, port
return "localhost", port
@pytest.fixture(scope="session")
def backend(scylla_container, redis_container):
scylla_host, scylla_port = scylla_container
def mongo_container(docker_ip, docker_services):
host = docker_ip
if os.path.exists("/.dockerenv"):
host = "mongo"
if docker_services is None:
port = 27017
else:
port = docker_services.port_for("mongodb", 27017)
return "localhost", port
@pytest.fixture(scope="session")
def backend(redis_container, mongo_container):
redis_host, redis_port = redis_container
mongo_host, mongo_port = mongo_container
config = {
"scylla": {"hosts": [(scylla_host, scylla_port)]},
"redis": {"host": redis_host, "port": redis_port},
"mongodb": {"host": mongo_host, "port": mongo_port},
}
app = AtlasApp(config)