Skip to content

Commit

Permalink
🎨 Format - ran black and foramt-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aybruhm committed Sep 7, 2023
1 parent 6130376 commit 7a5a1eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions agenta-backend/agenta_backend/models/db_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,26 @@ def initialize_client(self) -> AsyncIOMotorClient:
Returns an instance of `AsyncIOMotorClient` initialized \
with the provided `db_url`.
"""

client = AsyncIOMotorClient(self.db_url)
return client

def engine(self) -> AIOEngine:
"""
Returns an AIOEngine object with a specified database name based on the mode.
"""

if self.mode == "test":
aio_engine = AIOEngine(client=self.initialize_client, database="agenta_test")
aio_engine = AIOEngine(
client=self.initialize_client, database="agenta_test"
)
logger.info("Using test database...")
return aio_engine
elif self.mode == "default":
aio_engine = AIOEngine(client=self.initialize_client, database="agenta")
logger.info("Using default database")
return aio_engine

def remove_db(self) -> None:
client = MongoClient(self.db_url)
if self.mode == "default":
Expand Down
3 changes: 2 additions & 1 deletion agenta-backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ def test_app():
yield client # provide the test client to the tests
# teardown code goes here


@pytest.fixture(scope="function")
def test_db_engine():
# Initialize the DBEngine in 'test' mode
db_engine = DBEngine(mode="test")
test_engine = db_engine.engine()
yield test_engine
db_engine.remove_db()
db_engine.remove_db()

0 comments on commit 7a5a1eb

Please sign in to comment.