Merge "Fix the fault client returns 500 instend of 404"
[pti/o2.git] / tests / conftest.py
index 68da7c4..447351b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2022 Wind River Systems, Inc.
+# Copyright (C) 2022-2024 Wind River Systems, Inc.
 #
 #  Licensed under the Apache License, Version 2.0 (the "License");
 #  you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
 # pylint: disable=redefined-outer-name
 import shutil
 import subprocess
+import sys
 import time
 from pathlib import Path
 
@@ -27,6 +28,24 @@ from sqlalchemy import create_engine
 from sqlalchemy.orm import sessionmaker, clear_mappers
 from tenacity import retry, stop_after_delay
 from unittest.mock import MagicMock
+from mock_alchemy.mocking import UnifiedAlchemyMagicMock
+
+# Mock cgtsclient, dcmanagerclient, fmclient
+modules_to_mock = [
+    'cgtsclient',
+    'cgtsclient.client',
+    'cgtsclient.exc',
+    'dcmanagerclient',
+    'dcmanagerclient.api',
+    'dcmanagerclient.api.client',
+    'fmclient',
+    'fmclient.client',
+    'fmclient.common',
+    'fmclient.common.exceptions'
+]
+
+for module_name in modules_to_mock:
+    sys.modules[module_name] = MagicMock()
 
 from o2app.bootstrap import bootstrap
 from o2ims.views import configure_namespace
@@ -46,6 +65,13 @@ def mock_uow():
     return session, uow
 
 
+@pytest.fixture
+def mock_alchemy_uow():
+    session = UnifiedAlchemyMagicMock()
+    uow = unit_of_work.SqlAlchemyUnitOfWork(session_factory=session)
+    return session, uow
+
+
 @pytest.fixture
 def mock_flask_uow(mock_uow):
     session, uow = mock_uow