From 042d4c8fa8b3f7c76f8ea5991f3de29ad7ad8fd2 Mon Sep 17 00:00:00 2001 From: Miryam Schwartz Date: Sun, 8 Dec 2024 15:19:20 +0200 Subject: [PATCH] fix comments --- .../unit_tests/test_ibdiagnet_log_analyzer.py | 55 ++++++++--------- .../unit_tests/test_ufm_top_analyzer.py | 60 +++++++++---------- 2 files changed, 53 insertions(+), 62 deletions(-) diff --git a/plugins/ufm_log_analyzer_plugin/unit_tests/test_ibdiagnet_log_analyzer.py b/plugins/ufm_log_analyzer_plugin/unit_tests/test_ibdiagnet_log_analyzer.py index 3fbe9070..026f7447 100644 --- a/plugins/ufm_log_analyzer_plugin/unit_tests/test_ibdiagnet_log_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/unit_tests/test_ibdiagnet_log_analyzer.py @@ -1,20 +1,18 @@ -""" -@copyright: - Copyright © 2013-2024 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. +# @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 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. +# This software product is governed by the End User License Agreement +# provided with the software product. -@author: Miryam Schwartz -@date: Dec 08, 2024 -""" +# @author: Miryam Schwartz +# @date: Dec 08, 2024 -import unittest +import pytest import sys import os @@ -25,22 +23,19 @@ from loganalyze.log_analyzers.ibdiagnet_log_analyzer import IBDIAGNETLogAnalyzer -class TestIBDIAGNETLogAnalyzer(unittest.TestCase): - def setUp(self): - # Example initialization with dummy arguments - self.logs_csvs = [] - self.hours = 24 - self.dest_image_path = "/dummy/path" - self.analyzer = IBDIAGNETLogAnalyzer(self.logs_csvs, self.hours, self.dest_image_path) +@pytest.fixture +def analyzer(): + # Fixture to initialize the analyzer object + logs_csvs = [] + hours = 24 + dest_image_path = "/dummy/path" + return IBDIAGNETLogAnalyzer(logs_csvs, hours, dest_image_path) - def test_get_fabric_size(self): - # Mock the _log_data_sorted attribute - expected_fabric_size = {"switch_count": 10, "link_count": 50} # Example data - self.analyzer._log_data_sorted = expected_fabric_size # pylint: disable=protected-access +def test_get_fabric_size(analyzer): + # Mock the _log_data_sorted attribute + expected_fabric_size = {"switch_count": 10, "link_count": 50} # Example data + analyzer._log_data_sorted = expected_fabric_size # pylint: disable=protected-access - # Call the method and check the result - result = self.analyzer.get_fabric_size() - self.assertEqual(result, expected_fabric_size) - -if __name__ == "__main__": - unittest.main() + # Call the method and check the result + result = analyzer.get_fabric_size() + assert result == expected_fabric_size \ No newline at end of file diff --git a/plugins/ufm_log_analyzer_plugin/unit_tests/test_ufm_top_analyzer.py b/plugins/ufm_log_analyzer_plugin/unit_tests/test_ufm_top_analyzer.py index ce6a8deb..6cebb7cb 100644 --- a/plugins/ufm_log_analyzer_plugin/unit_tests/test_ufm_top_analyzer.py +++ b/plugins/ufm_log_analyzer_plugin/unit_tests/test_ufm_top_analyzer.py @@ -1,20 +1,18 @@ -""" -@copyright: - Copyright © 2013-2024 NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. +# @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 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. +# This software product is governed by the End User License Agreement +# provided with the software product. -@author: Miryam Schwartz -@date: Dec 08, 2024 -""" +# @author: Miryam Schwartz +# @date: Dec 08, 2024 -import unittest +import pytest import sys import os @@ -24,26 +22,24 @@ from loganalyze.log_analyzers.ufm_top_analyzer import UFMTopAnalyzer -class TestUFMTopAnalyzer(unittest.TestCase): - def setUp(self): - self.analyzer = UFMTopAnalyzer() +@pytest.fixture +def analyzer(): + # Fixture to initialize the analyzer object + return UFMTopAnalyzer() - def test_add_analyzer(self): - mock_analyzer_1 = "Analyzer1" - mock_analyzer_2 = "Analyzer2" +def test_add_analyzer(analyzer): + mock_analyzer_1 = "Analyzer1" + mock_analyzer_2 = "Analyzer2" - # Initially, the list should be empty - self.assertEqual(len(self.analyzer._analyzers), 0) # pylint: disable=protected-access + # Initially, the list should be empty + assert len(analyzer._analyzers) == 0 # pylint: disable=protected-access - # Add first analyzer and check the length - self.analyzer.add_analyzer(mock_analyzer_1) - self.assertEqual(len(self.analyzer._analyzers), 1) # pylint: disable=protected-access - self.assertIn(mock_analyzer_1, self.analyzer._analyzers) # pylint: disable=protected-access + # Add first analyzer and check the length + analyzer.add_analyzer(mock_analyzer_1) + assert len(analyzer._analyzers) == 1 # pylint: disable=protected-access + assert mock_analyzer_1 in analyzer._analyzers # pylint: disable=protected-access - # Add second analyzer and check the updated length - self.analyzer.add_analyzer(mock_analyzer_2) - self.assertEqual(len(self.analyzer._analyzers), 2) # pylint: disable=protected-access - self.assertIn(mock_analyzer_2, self.analyzer._analyzers) # pylint: disable=protected-access - -if __name__ == "__main__": - unittest.main() + # Add second analyzer and check the updated length + analyzer.add_analyzer(mock_analyzer_2) + assert len(analyzer._analyzers) == 2 # pylint: disable=protected-access + assert mock_analyzer_2 in analyzer._analyzers # pylint: disable=protected-access