Skip to content

Commit

Permalink
fix other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone committed Nov 5, 2024
1 parent 2403179 commit 83c0180
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions openbb_platform/core/tests/app/logs/test_handlers_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def test_handlers_added_correctly():
settings = Mock()
settings.verbosity = 20
settings.handler_list = ["stdout", "stderr", "noop", "file", "posthog"]
settings.log_collect = True
settings.logging_suppress = False
logger = logging.getLogger("test_handlers_added_correctly")
handlers_manager = HandlersManager(logger=logger, settings=settings)
handlers_manager.setup()
Expand Down
20 changes: 16 additions & 4 deletions openbb_platform/core/tests/app/logs/test_logging_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,24 @@
# pylint: disable=redefined-outer-name, protected-access


class MockSystemSettings:
"""Mock system settings."""

def __init__(self):
"""Initialize the mock system settings."""
self.logging_suppress = False
self.log_collect = True


class MockLoggingSettings:
"""Mock logging settings."""

def __init__(self, system_settings, user_settings):
"""Initialize the mock logging settings."""
self.system_settings = system_settings
self.user_settings = user_settings
self.logging_suppress = False
self.log_collect = True


class MockOBBject(BaseModel):
Expand All @@ -32,7 +43,7 @@ class MockOBBject(BaseModel):
@pytest.fixture(scope="function")
def logging_service():
"""Return a LoggingService instance."""
mock_system_settings = Mock()
mock_system_settings = MockSystemSettings()
mock_user_settings = Mock()
mock_setup_handlers = Mock()
mock_log_startup = Mock()
Expand Down Expand Up @@ -112,6 +123,7 @@ class MockCredentials(BaseModel):
credentials=MockCredentials(username="username", password="password"),
)
logging_service._system_settings = "your_system_settings"
logging_service._system_settings

logging_service._log_startup(
route="test_route", custom_headers={"X-OpenBB-Test": "test"}
Expand All @@ -138,7 +150,7 @@ class MockCredentials(BaseModel):
[
(
"mock_settings",
"mock_system",
MockSystemSettings(),
"mock_route",
"mock_func",
{},
Expand All @@ -149,7 +161,7 @@ class MockCredentials(BaseModel):
),
(
"mock_settings",
"mock_system",
MockSystemSettings(),
"mock_route",
"mock_func",
{},
Expand All @@ -163,7 +175,7 @@ class MockCredentials(BaseModel):
),
(
"mock_settings",
"mock_system",
MockSystemSettings(),
"login",
"mock_func",
{},
Expand Down

0 comments on commit 83c0180

Please sign in to comment.