Coverage for intelligence_toolkit/tests/unit/match_entity_records/test_prompts.py: 100%

41 statements  

« 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# 

4 

5import pytest 

6 

7from intelligence_toolkit.match_entity_records.prompts import ( 

8 list_prompts, 

9 report_prompt, 

10 user_prompt, 

11) 

12 

13 

14class TestReportPrompt: 

15 def test_report_prompt_structure(self) -> None: 

16 """Test that report_prompt contains expected structure.""" 

17 assert "Goal:" in report_prompt 

18 assert "RELATEDNESS" in report_prompt 

19 assert "scale of 0-10" in report_prompt 

20 assert "{data}" in report_prompt 

21 assert "Group ID" in report_prompt 

22 assert "Relatedness" in report_prompt 

23 assert "Explanation" in report_prompt 

24 

25 def test_report_prompt_format(self) -> None: 

26 """Test that report_prompt can be formatted with data.""" 

27 test_data = "test_data_value" 

28 formatted = report_prompt.format(data=test_data) 

29 assert "test_data_value" in formatted 

30 assert "{data}" not in formatted 

31 

32 

33class TestUserPrompt: 

34 def test_user_prompt_structure(self) -> None: 

35 """Test that user_prompt contains expected guidance.""" 

36 assert "Factors indicating unrelatedness" in user_prompt 

37 assert "Factors indicating relatedness" in user_prompt 

38 assert "Factors that should be ignored" in user_prompt 

39 assert "Factors that should be considered" in user_prompt 

40 assert "spelling" in user_prompt 

41 assert "formatting" in user_prompt 

42 assert "missing values" in user_prompt 

43 

44 def test_user_prompt_is_string(self) -> None: 

45 """Test that user_prompt is a non-empty string.""" 

46 assert isinstance(user_prompt, str) 

47 assert len(user_prompt) > 0 

48 

49 

50class TestListPrompts: 

51 def test_list_prompts_structure(self) -> None: 

52 """Test that list_prompts contains expected keys.""" 

53 assert "report_prompt" in list_prompts 

54 assert "user_prompt" in list_prompts 

55 assert "safety_prompt" in list_prompts 

56 

57 def test_list_prompts_values(self) -> None: 

58 """Test that list_prompts contains correct values.""" 

59 assert list_prompts["report_prompt"] == report_prompt 

60 assert list_prompts["user_prompt"] == user_prompt 

61 assert isinstance(list_prompts["safety_prompt"], str) 

62 

63 def test_safety_prompt_content(self) -> None: 

64 """Test that safety_prompt contains expected content.""" 

65 safety_prompt = list_prompts["safety_prompt"] 

66 assert len(safety_prompt) > 0 

67 assert isinstance(safety_prompt, str)