Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Miryam-Schwartz committed Dec 11, 2024
1 parent 74c6af0 commit 72703ae
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ufm_log_analyzer_ci_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ jobs:
cd $SCRIPT_DIR
pip install -r src/loganalyze/requirements.txt
pip install pytest
pip install pytest==8.3.4
pytest unit_tests
19 changes: 19 additions & 0 deletions plugins/ufm_log_analyzer_plugin/unit_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# @copyright:
# Copyright © 2013-2024 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED.

# This software product is a proprietary product of Nvidia Corporation and its affiliates
# (the "Company") and all right, title, and interest in and to the
# software product, including all associated intellectual property rights,
# are and shall remain exclusively with the Company.

# This software product is governed by the End User License Agreement
# provided with the software product.

# @author: Miryam Schwartz
# @date: Dec 08, 2024

import sys
import os

sys.path.append(os.getcwd() + "/src") # Add the src directory containing loganalyze
sys.path.append("/".join(os.getcwd().split("/")[:-2])) # Add the root project directory
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,27 @@
# @author: Miryam Schwartz
# @date: Dec 08, 2024



import pytest
from unittest.mock import MagicMock

from loganalyze.log_analyzers.ibdiagnet_log_analyzer import IBDIAGNETLogAnalyzer


@pytest.fixture
def analyzer(fabric_size_data):
# Mock the constructor of IBDIAGNETLogAnalyzer
mock_analyzer = MagicMock(spec=IBDIAGNETLogAnalyzer)

# Mock the _log_data_sorted attribute
mock_analyzer._log_data_sorted = fabric_size_data

# Mock the get_fabric_size method to return the _log_data_sorted attribute
mock_analyzer.get_fabric_size.return_value = fabric_size_data

# Return the mocked analyzer instance
return mock_analyzer
# Define a test-specific subclass
class TestIBDIAGNETLogAnalyzer(IBDIAGNETLogAnalyzer):
def __init__(self, fabric_size_data):
# Do not call the parent constructor, set up only what's needed for the test
self._log_data_sorted = fabric_size_data

@pytest.fixture
def fabric_size_data():
# Shared mock data
return {"switch_count": 10, "link_count": 50}

@pytest.fixture
def analyzer(fabric_size_data):
# Return an instance of the test-specific subclass
return TestIBDIAGNETLogAnalyzer(fabric_size_data)

def test_get_fabric_size(analyzer, fabric_size_data):
# Call the method and check the result
result = analyzer.get_fabric_size()
assert result == fabric_size_data, "get_fabric_size should return _log_data_sorted"
assert result == fabric_size_data, "get_fabric_size should return _log_data_sorted"

0 comments on commit 72703ae

Please sign in to comment.