please look at how these tests are set up:

```
import pytest
from chat.chat import chat_with_model, process_file_updates, detect_file_updates, calculate_diff, remove_full_content_from_response
from app_state import get_app_state
from efc.efc_cache import get_file_context
from unittest.mock import AsyncMock, MagicMock


@pytest.fixture
def mock_app_state():
    class MockAppState:
        def __init__(self):
            self.active_project = "/path/to/active_project"
            self.conversation_history = []
            self.file_histories = {}
            self.token_usage = {}

        def get_active_project_tree_string(self):
            return "Mocked project tree"

    return MockAppState()


@pytest.fixture
def mock_file_context():
    class MockFileContextTracker:
        def __init__(self):
            self.tracked_files = {}

        def generate_context_awareness_prompt(self, app_state) -> str:
            if not self.tracked_files:
                return "No files in context."
            context = ""
            for relative_path in self.tracked_files:
                content = self.get_file_content(relative_path)
                context += f"- **{relative_path}**:\n```\n{content}\n```\n"
            return context

        def get_file_content(self, relative_path: str) -> str:
            return self.tracked_files.get(relative_path, "")

        def add_or_update_file(self, relative_path: str, content: str, operation: str) -> None:
            print(f"MockFileContextTracker: Adding '{relative_path}' with content '{content}' via operation '{operation}'")
            self.tracked_files[relative_path] = content

    return MockFileContextTracker()


def test_detect_file_updates():
    assistant_message = "Fresh content for file1.txt: ```diff\n+ Added line\n- Removed line\n```"
    updates = detect_file_updates(assistant_message)
    assert updates == {"file1.txt": "+ Added line\n- Removed line"}


def test_calculate_diff():
    old_content = "Line1\nLine2\nLine3"
    new_content = "Line1\nLine2 modified\nLine3"
    diff = calculate_diff(old_content, new_content)
    expected_diff = """--- 
+++ 
@@ -1,3 +1,3 @@
 Line1
-Line2
+Line2 modified
 Line3"""
    assert diff == expected_diff


def test_remove_full_content_from_response():
    assistant_message = "Some message. Fresh content for file1.txt: ```diff\n+ Added line\n- Removed line\n``` More text."
    cleaned_message = remove_full_content_from_response(assistant_message, 'file1.txt')
    assert cleaned_message == "Some message. More text."


@pytest.mark.asyncio
async def test_initial_file_addition(mock_app_state, mock_file_context, monkeypatch):
    user_input = "Create file1.txt"

    # 1. Mock AI client
    ai_client_mock = AsyncMock()

    # 2. Mock the response returned by create_message
    create_message_response_mock = MagicMock(
        usage=MagicMock(
            prompt_tokens=10,
            completion_tokens=20,
            total_tokens=30,
            cache_creation_input_tokens=5,
            cache_read_input_tokens=5
        )
    )
    ai_client_mock.create_message.return_value = create_message_response_mock

    # 3. Mock the extract_response method on the AI client with a relative path
    ai_client_mock.extract_response = AsyncMock(return_value="Added file1.txt to context.")

    # 4. Apply monkeypatch to replace AIClientFactory.get_ai_client with our mock
    monkeypatch.setattr("chat.chat.AIClientFactory.get_ai_client", lambda x: ai_client_mock)

    # 5. Apply monkeypatch to replace get_app_state to return mock_app_state
    monkeypatch.setattr("chat.chat.get_app_state", lambda: mock_app_state)

    # 6. Apply monkeypatch to replace get_file_context to return mock_file_context
    monkeypatch.setattr("chat.chat.get_file_context", lambda: mock_file_context)

    # 7. Call the function under test
    assistant_response = await chat_with_model(user_input, MagicMock(), "gpt-4")

    # 8. Print internal states for debugging
    print("Conversation History:", mock_app_state.conversation_history)
    print("Tracked Files:", mock_file_context.tracked_files)

    # 9. Check that the conversation_history has two messages
    expected_conversation_length = 2  # User input + Assistant response
    assert len(mock_app_state.conversation_history) == expected_conversation_length, \
        f"Expected {expected_conversation_length} messages in conversation_history, found {len(mock_app_state.conversation_history)}"

    # 10. Check the order and content of messages
    assert mock_app_state.conversation_history[0]['role'] == 'user', \
        f"Expected first message role to be 'user', got {mock_app_state.conversation_history[0]['role']}"

    assert mock_app_state.conversation_history[0]['content'] == 'Create file1.txt', \
        f"Unexpected user message content: {mock_app_state.conversation_history[0]['content']}"

    expected_assistant_content = "Added file1.txt to context.\nI've added `file1.txt` to the context."
    assert mock_app_state.conversation_history[1]['role'] == 'assistant', \
        f"Expected second message role to be 'assistant', got {mock_app_state.conversation_history[1]['role']}"

    assert mock_app_state.conversation_history[1]['content'] == expected_assistant_content, \
        f"Unexpected assistant message content: {mock_app_state.conversation_history[1]['content']}"

    # 11. Check that FileContextTracker was updated correctly
    assert "file1.txt" in mock_file_context.tracked_files, \
        f"Expected 'file1.txt' to be in tracked_files, got {list(mock_file_context.tracked_files.keys())}"

    assert mock_file_context.tracked_files["file1.txt"] == "", \
        f"Expected tracked_files['file1.txt'] to be an empty string, got {mock_file_context.tracked_files.get('file1.txt')}"

```