mirror of
https://github.com/bec-project/bec_atlas.git
synced 2025-07-14 15:01:48 +02:00
feat: added support for mongodb
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user