picogl.tests.test_object_renderer

Unit tests for the ObjectRenderer class in the PicoGL OpenGL backend.

This module contains a comprehensive suite of unit tests for verifying the correctness, robustness, and interface of the picogl.renderer.object.ObjectRenderer class, which provides unified rendering for textured and untextured objects.

The tests cover:

  • Object initialization with various parameters

  • Shader initialization and compilation

  • VAO and VBO setup for different data types

  • Rendering pipeline and drawing operations

  • Texture loading and binding

  • Error handling and edge cases

  • Data validation and type conversion

Dependencies:
  • unittest (standard library)

  • unittest.mock.MagicMock for OpenGL function mocking

  • numpy for test data

  • picogl.renderer.object.ObjectRenderer

  • picogl.renderer.meshdata.MeshData

To run the tests:

python -m unittest picogl.tests.test_object_renderer

Classes

TestObjectRenderer

Test cases for ObjectRenderer class.

Module Contents

class picogl.tests.test_object_renderer.TestObjectRenderer(methodName='runTest')[source]

Bases: unittest.TestCase

Test cases for ObjectRenderer class.

setUp()[source]

Set up test fixtures before each test method.

tearDown()[source]

Clean up after each test method.

test_initialization_without_texture()[source]

Test ObjectRenderer initialization without texture.

test_initialization_with_texture()[source]

Test ObjectRenderer initialization with texture.

test_initialization_with_path_objects()[source]

Test ObjectRenderer initialization with Path objects.

test_initialization_with_none_context()[source]

Test ObjectRenderer initialization with None context.

test_initialize_shaders_with_existing_context()[source]

Test initialize_shaders with existing context.

test_initialize_shaders_with_custom_glsl_dir()[source]

Test initialize_shaders with custom GLSL directory.

test_initialize_shaders_with_none_context()[source]

Test initialize_shaders with None context creates new one.

test_initialize_with_texture_and_uvs()[source]

Test initialize method with texture and UVs.

test_initialize_without_texture_with_colors_and_normals()[source]

Test initialize method without texture, with colors and normals.

test_initialize_without_texture_without_colors()[source]

Test initialize method without texture and without colors.

test_initialize_with_existing_vaos()[source]

Test initialize method with existing VAOs dictionary.

test_render_with_show_model_true()[source]

Test render method with show_model=True.

test_render_with_show_model_false()[source]

Test render method with show_model=False.

test_draw_model_without_texture()[source]

Test _draw_model method without texture.

test_draw_model_with_texture()[source]

Test _draw_model method with texture.

test_draw_model_without_texture_object()[source]

Test _draw_model method with use_texture=True but no texture object.

test_vertex_count_calculation()[source]

Test vertex count calculation in initialization.

test_texture_loading_with_valid_path()[source]

Test texture loading with valid path.

test_texture_loading_without_texture_file()[source]

Test texture loading without texture file.

test_texture_loading_without_base_dir()[source]

Test texture loading without base directory.

test_renderer_base_inheritance()[source]

Test that ObjectRenderer inherits from RendererBase.

test_initialization_with_minimal_mesh_data()[source]

Test initialization with minimal mesh data (only vertices).

test_initialization_with_texture_but_no_uvs()[source]

Test initialization with texture enabled but no UVs in mesh data.

test_log_parameter_calls()[source]

Test that log.parameter is called for texture usage.

test_finalize_render_inheritance()[source]

Test that _finalize_render is inherited from RendererBase.