# test_properties_progress_display.py """ Property-based tests for progress display accuracy. Tests that progress display correctly reflects the current position in the queue and total messages in the dataset. """ import pytest from hypothesis import given, strategies as st, settings, HealthCheck from datetime import datetime from src.core.verification_models import ( VerificationRecord, VerificationSession, TestMessage, TestDataset, ) from src.interface.verification_ui import VerificationUIComponents def test_message_strategy(): """Generate random test messages.""" return st.builds( TestMessage, message_id=st.text( alphabet="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_", min_size=1, max_size=20, ), text=st.text(min_size=1, max_size=500), pre_classified_label=st.sampled_from(["green", "yellow", "red"]), ) class TestProgressDisplayAccuracy: """ **Feature: verification-mode, Property 7: Progress Display is Accurate** Tests that progress display correctly reflects current position and total messages. """ @given( current_index=st.integers(min_value=0, max_value=99), total_messages=st.integers(min_value=1, max_value=100), ) @settings(suppress_health_check=[HealthCheck.function_scoped_fixture]) def test_progress_display_format(self, current_index, total_messages): """ **Feature: verification-mode, Property 7: Progress Display is Accurate** **Validates: Requirements 1.3, 5.1** For any current index and total messages, the progress display should show "Message X of Y" where X = current_index + 1 and Y = total_messages. """ # Ensure current_index is within bounds if current_index >= total_messages: current_index = total_messages - 1 # Get progress display progress = VerificationUIComponents.update_progress_display( current_index, total_messages ) # Verify format contains "Progress" assert "Progress" in progress # Extract the numbers from the progress string # Format: "📊 **Progress:** X of Y messages (Z%)" import re match = re.search(r'(\d+) of (\d+)', progress) assert match is not None, f"Could not find 'X of Y' pattern in: {progress}" message_number = int(match.group(1)) total_from_display = int(match.group(2)) # Verify message number is correct (1-based) assert message_number == current_index + 1 # Verify total is correct assert total_from_display == total_messages def test_progress_display_first_message(self): """ **Feature: verification-mode, Property 7: Progress Display is Accurate** **Validates: Requirements 1.3, 5.1** When at the first message (index 0), progress should show "1 of Y". """ progress = VerificationUIComponents.update_progress_display(0, 10) assert "1 of 10" in progress assert "Progress:" in progress def test_progress_display_last_message(self): """ **Feature: verification-mode, Property 7: Progress Display is Accurate** **Validates: Requirements 1.3, 5.1** When at the last message, progress should show "Y of Y". """ progress = VerificationUIComponents.update_progress_display(9, 10) assert "10 of 10" in progress assert "Progress:" in progress def test_progress_display_middle_message(self): """ **Feature: verification-mode, Property 7: Progress Display is Accurate** **Validates: Requirements 1.3, 5.1** When at a middle message, progress should show correct position. """ progress = VerificationUIComponents.update_progress_display(4, 10) assert "5 of 10" in progress assert "Progress:" in progress def test_progress_display_single_message(self): """ **Feature: verification-mode, Property 7: Progress Display is Accurate** **Validates: Requirements 1.3, 5.1** When there is only one message, progress should show "1 of 1". """ progress = VerificationUIComponents.update_progress_display(0, 1) assert "1 of 1" in progress assert "Progress:" in progress @given(st.integers(min_value=1, max_value=1000)) def test_progress_display_large_dataset(self, total_messages): """ **Feature: verification-mode, Property 7: Progress Display is Accurate** **Validates: Requirements 1.3, 5.1** For any large dataset size, progress display should correctly show position. """ import re # Test at various positions for position_ratio in [0.0, 0.25, 0.5, 0.75, 0.99]: current_index = int(total_messages * position_ratio) if current_index >= total_messages: current_index = total_messages - 1 progress = VerificationUIComponents.update_progress_display( current_index, total_messages ) # Extract numbers using regex # Format: "📊 **Progress:** X of Y messages (Z%)" match = re.search(r'(\d+) of (\d+)', progress) assert match is not None, f"Could not find 'X of Y' pattern in: {progress}" message_number = int(match.group(1)) total_from_display = int(match.group(2)) # Verify correctness assert message_number == current_index + 1 assert total_from_display == total_messages def test_progress_display_contains_emoji(self): """ **Feature: verification-mode, Property 7: Progress Display is Accurate** **Validates: Requirements 1.3, 5.1** Progress display should contain the progress emoji for visual clarity. """ progress = VerificationUIComponents.update_progress_display(0, 10) assert "📊" in progress def test_progress_display_contains_messages_text(self): """ **Feature: verification-mode, Property 7: Progress Display is Accurate** **Validates: Requirements 1.3, 5.1** Progress display should contain "messages" text. """ progress = VerificationUIComponents.update_progress_display(0, 10) # The implementation uses "messages" in the format assert "messages" in progress