Skip to content

Commit

Permalink
Add more tests for test_recorder
Browse files Browse the repository at this point in the history
Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh committed May 18, 2023
1 parent 5991ed9 commit 55592fe
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/test_workflow/test_recorder/test_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def save_test_result_data(self, test_result_data: TestResultData) -> None:


class TestResultsLogs(LogRecorder):
__test__ = False # type:ignore
parent_class: TestRecorder

def __init__(self, parent_class: TestRecorder) -> None:
Expand Down
33 changes: 32 additions & 1 deletion tests/tests_test_workflow/test_recorder/test_test_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from typing import Any
from unittest.mock import MagicMock, Mock, call, mock_open, patch

from test_workflow.test_recorder.test_recorder import LocalClusterLogs, TestRecorder
from test_workflow.test_recorder.test_recorder import LocalClusterLogs, TestRecorder, TestResultsLogs


@patch("os.makedirs")
Expand Down Expand Up @@ -146,3 +146,34 @@ def test(self) -> None:
logs.save_test_result_data(mock_test_result_data)

mock_parent_class._copy_log_files.assert_called_once_with(mock_test_result_data.log_files, dest_directory)


class TestTestResultsLogs(unittest.TestCase):

def test(self) -> None:
mock_parent_class = MagicMock()

mock_parent_class._create_base_folder_structure.return_value = "test_base"

mock_parent_class._copy_log_files = MagicMock()

logs = TestResultsLogs(mock_parent_class)

mock_test_result_data = MagicMock()

dest_directory = "test_base"

source_file_1 = "stdout.txt"
source_file_2 = "stderr.txt"

mock_test_result_data.log_files = {
source_file_1,
source_file_2
}
mock_test_result_data.component_name = "sql"
mock_test_result_data.component_test_config = "with-security"

logs.save_test_result_data(mock_test_result_data)

mock_parent_class._copy_log_files.assert_called_once_with(mock_test_result_data.log_files, dest_directory)
mock_parent_class._generate_yml.assert_called_once_with(mock_test_result_data, dest_directory)

0 comments on commit 55592fe

Please sign in to comment.