Skip to content

Commit

Permalink
Added test_dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
cszsol committed Nov 20, 2024
1 parent 9a7a8e5 commit cdd67c8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
22 changes: 22 additions & 0 deletions swarm_copy_tests/app/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from swarm_copy.app.dependencies import get_settings
from swarm_copy.app.main import app


def test_settings_endpoint(app_client, dont_look_at_env_file):
settings = app.dependency_overrides[get_settings]()
response = app_client.get("/settings")

replace_secretstr = settings.model_dump()
replace_secretstr["keycloak"]["password"] = "**********"
replace_secretstr["openai"]["token"] = "**********"
assert response.json() == replace_secretstr


def test_readyz(app_client):
response = app_client.get(
"/",
)

body = response.json()
assert isinstance(body, dict)
assert body["status"] == "ok"
27 changes: 27 additions & 0 deletions tests/app/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,33 @@ def test_get_connection_string_no_prefix(monkeypatch, patch_required_env):
assert result is None, "should return None when prefix is not set"


<<<<<<< Updated upstream
=======
def test_get_engine(monkeypatch, patch_required_env):
monkeypatch.setenv("NEUROAGENT_DB__PREFIX", "prefix")

settings = Settings()

connection_string = "https://localhost"
retval = get_engine(settings=settings, connection_string=connection_string)
assert retval is not None


@patch("neuroagent.app.dependencies.create_engine")
def test_get_engine_no_connection_string(
create_engine_mock, monkeypatch, patch_required_env
):
create_engine_mock.return_value = Mock()

monkeypatch.setenv("NEUROAGENT_DB__PREFIX", "prefix")

settings = Settings()

retval = get_engine(settings=settings, connection_string=None)
assert retval is None


>>>>>>> Stashed changes
@patch("sqlalchemy.orm.Session")
@pytest.mark.asyncio
async def test_get_session_success(_):
Expand Down

0 comments on commit cdd67c8

Please sign in to comment.