Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
renan-souza committed Dec 9, 2024
1 parent 7798b64 commit 7cf78cf
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea
**/*mlruns*
**/*.env*
**/*build*
**/*egg*
**/*pycache*
Expand Down
2 changes: 1 addition & 1 deletion src/flowcept/commons/daos/docdb_dao/lmdb_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def workflow_query(

def close(self):
"""Close lmdb."""
self.logger.warn("We are not closing this database.")
self.logger.warning("We are not closing this database.")
return
# self._env.close()
# self._is_closed = True
6 changes: 3 additions & 3 deletions src/flowcept/flowcept_api/db_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from flowcept.commons.flowcept_dataclasses.task_object import TaskObject
from flowcept.commons.flowcept_logger import FlowceptLogger

from flowcept.configs import DATABASES
from flowcept.configs import MONGO_ENABLED, LMDB_ENABLED


class DBAPI(object):
Expand All @@ -37,12 +37,12 @@ def __init__(
if self.with_webserver:
raise NotImplementedError("We did not implement webserver API for this yet.")

if "mongodb" in DATABASES and DATABASES["mongodb"].get("enabled", False):
if MONGO_ENABLED:
# Currently MongoDB has precedence over LMDB if both are enabled.
from flowcept.commons.daos.docdb_dao.mongodb_dao import MongoDBDAO

self._dao = MongoDBDAO(create_indices=False)
elif "lmdb" in DATABASES and DATABASES["lmdb"].get("enabled", False):
elif LMDB_ENABLED:
from flowcept.commons.daos.docdb_dao.lmdb_dao import LMDBDAO

self._dao = LMDBDAO()
Expand Down
8 changes: 6 additions & 2 deletions tests/api/db_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@ def test_wf_dao(self):
wf2.interceptor_ids = ["1234"]
assert Flowcept.db.insert_or_update_workflow(wf2)
wf_obj = Flowcept.db.get_workflow(wf2_id)
assert len(wf_obj.interceptor_ids) == 2
if MONGO_ENABLED:
# TODO: note that some of these tests currently only work on MongoDB because
# updating is not yet implemented in LMDB
assert len(wf_obj.interceptor_ids) == 2
wf2.machine_info = {"123": tel.capture_machine_info()}
assert Flowcept.db.insert_or_update_workflow(wf2)
wf_obj = Flowcept.db.get_workflow(wf2_id)
assert wf_obj
wf2.machine_info = {"1234": tel.capture_machine_info()}
assert Flowcept.db.insert_or_update_workflow(wf2)
wf_obj = Flowcept.db.get_workflow(wf2_id)
assert len(wf_obj.machine_info) == 2
if MONGO_ENABLED:
assert len(wf_obj.machine_info) == 2

@unittest.skipIf(not MONGO_ENABLED, "MongoDB is disabled")
def test_save_blob(self):
Expand Down
3 changes: 2 additions & 1 deletion tests/api/query_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Status,
)
from flowcept.commons.flowcept_logger import FlowceptLogger
from flowcept.configs import WEBSERVER_PORT, WEBSERVER_HOST
from flowcept.configs import WEBSERVER_PORT, WEBSERVER_HOST, MONGO_ENABLED
from flowcept.flowcept_api.task_query_api import TaskQueryAPI
from flowcept.flowcept_webserver.app import app, BASE_ROUTE
from flowcept.flowcept_webserver.resources.query_rsrc import TaskQuery
Expand Down Expand Up @@ -129,6 +129,7 @@ def gen_mock_data(size=1, with_telemetry=False):
return new_docs, new_task_ids


@unittest.skipIf(not MONGO_ENABLED, "MongoDB is disabled")
class QueryTest(unittest.TestCase):
URL = f"http://{WEBSERVER_HOST}:{WEBSERVER_PORT}{BASE_ROUTE}{TaskQuery.ROUTE}"

Expand Down

0 comments on commit 7cf78cf

Please sign in to comment.