Coverage for intelligence_toolkit/tests/unit/match_entity_records/test_init.py: 100%
24 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-16 13:41 -0300
« prev ^ index » next coverage.py v7.10.7, created at 2025-10-16 13:41 -0300
1# Copyright (c) 2024 Microsoft Corporation. All rights reserved.
2# Licensed under the MIT license. See LICENSE file in the project.
3#
5from pathlib import Path
6from unittest.mock import mock_open, patch
8import pytest
10from intelligence_toolkit.match_entity_records import get_readme
13class TestGetReadme:
14 def test_get_readme_success(self) -> None:
15 """Test get_readme successfully reads README.md."""
16 mock_readme_content = "# Match Entity Records\n\nThis is a test README."
18 with patch("builtins.open", mock_open(read_data=mock_readme_content)):
19 result = get_readme()
21 assert result == mock_readme_content
22 assert "Match Entity Records" in result
24 def test_get_readme_file_structure(self) -> None:
25 """Test that get_readme reads from correct path."""
26 mock_content = "Test content"
28 with patch("builtins.open", mock_open(read_data=mock_content)) as mock_file:
29 get_readme()
30 # Verify open was called
31 mock_file.assert_called_once()
32 # Get the path that was used
33 call_args = mock_file.call_args[0][0]
34 # Should end with README.md
35 assert str(call_args).endswith("README.md")
37 def test_get_readme_returns_string(self) -> None:
38 """Test that get_readme returns a string."""
39 mock_content = "Test README content"
41 with patch("builtins.open", mock_open(read_data=mock_content)):
42 result = get_readme()
44 assert isinstance(result, str)
45 assert len(result) > 0