import pytest
from unittest.mock import patch, MagicMock

def test_dynamic_background_rendering():
 # Mock OpenGL before importing
 with patch("src.shader_manager.gl") as mock_gl:
  from src.shader_manager import ShaderManager
  
  # Setup mock return values
  mock_gl.glCreateProgram.return_value = 1
  mock_gl.glCreateShader.return_value = 2
  mock_gl.glGetShaderiv.return_value = 1 # GL_TRUE
  mock_gl.glGetProgramiv.return_value = 1 # GL_TRUE
  mock_gl.glGetUniformLocation.return_value = 10
  
  manager = ShaderManager()
  manager.setup_background_shader()
  
  # Verify background program was created
  assert manager.bg_program == 1
  assert mock_gl.glCreateProgram.called
  
  # Render background
  manager.render_background(800, 600, 1.0)
  
  # Verify OpenGL calls
  mock_gl.glUseProgram.assert_any_call(1)
  mock_gl.glDrawArrays.assert_called_with(mock_gl.GL_TRIANGLE_STRIP, 0, 4)
  mock_gl.glUseProgram.assert_any_call(0)
  
  # Verify uniforms were updated
  mock_gl.glUniform1f.assert_called()
  mock_gl.glUniform2f.assert_called()
