picogl.tests.test_legacy_glmesh

Unit tests for the LegacyGLMesh 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.legacy_glmesh.LegacyGLMesh class, which manages GPU-resident mesh data for legacy OpenGL compatibility.

The tests cover:

  • Object initialization with various mesh data

  • from_mesh_data class method

  • GPU buffer upload and allocation with legacy VBOs

  • Dynamic attribute generation for layout descriptors

  • OpenGL binding/unbinding operations with legacy client states

  • Drawing operations with legacy OpenGL functions

  • Context manager functionality

  • Resource cleanup and memory management

  • 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.legacy_glmesh.LegacyGLMesh

  • picogl.renderer.meshdata.MeshData

To run the tests:

python -m unittest picogl.tests.test_legacy_glmesh

Classes

TestLegacyGLMesh

Test cases for LegacyGLMesh class.

Module Contents

class picogl.tests.test_legacy_glmesh.TestLegacyGLMesh(methodName='runTest')[source]

Bases: unittest.TestCase

Test cases for LegacyGLMesh class.

setUp()[source]

Set up test fixtures before each test method.

tearDown()[source]

Clean up after each test method.

test_initialization_with_all_parameters()[source]

Test LegacyGLMesh initialization with all parameters.

test_initialization_with_minimal_parameters()[source]

Test LegacyGLMesh initialization with only vertices and faces.

test_initialization_with_empty_faces()[source]

Test LegacyGLMesh initialization with empty faces raises error.

test_initialization_data_type_conversion()[source]

Test that data is properly converted to correct types.

test_initialization_array_reshaping()[source]

Test that arrays are properly reshaped.

test_from_mesh_data_with_all_attributes()[source]

Test from_mesh_data with all MeshData attributes.

test_from_mesh_data_with_minimal_attributes()[source]

Test from_mesh_data with minimal MeshData attributes.

test_from_mesh_data_without_uvs()[source]

Test from_mesh_data without UVs attribute.

test_generate_dynamic_attributes_without_uvs()[source]

Test generate_dynamic_attributes without UVs.

test_generate_dynamic_attributes_with_uvs()[source]

Test generate_dynamic_attributes with UVs.

test_upload_first_time()[source]

Test upload method for the first time.

test_upload_already_uploaded()[source]

Test upload method when already uploaded.

test_upload_with_uvs()[source]

Test upload method with UVs.

test_upload_without_uvs()[source]

Test upload method without UVs.

test_upload_vbo_parameters()[source]

Test that VBOs are added with correct parameters.

test_ebo_parameters()[source]

Test that EBO is added with correct parameters.

test_bind_with_uploaded_mesh()[source]

Test bind method with uploaded mesh.

test_bind_without_upload()[source]

Test bind method without upload raises error.

test_unbind_with_vao()[source]

Test unbind method with VAO.

test_unbind_without_vao()[source]

Test unbind method without VAO.

test_delete_with_vao()[source]

Test delete method with VAO.

test_delete_without_vao()[source]

Test delete method without VAO.

test_context_manager()[source]

Test that LegacyGLMesh can be used as a context manager.

test_draw_with_uploaded_mesh()[source]

Test draw method with uploaded mesh.

test_draw_with_custom_mode()[source]

Test draw method with custom drawing mode.

test_draw_without_upload()[source]

Test draw method without upload handles error.

test_draw_with_exception_handling()[source]

Test draw method with exception handling.

test_vertex_count_calculation()[source]

Test vertex count calculation.

test_data_validation()[source]

Test data validation and type checking.

test_default_color_generation()[source]

Test default colour generation.

test_default_normal_generation()[source]

Test default normal generation.

test_default_uv_generation()[source]

Test default UV generation.

test_mesh_data_integration()[source]

Test integration with MeshData class.

test_legacy_client_states_integration()[source]

Test integration with legacy client states.

test_attribute_spec_properties()[source]

Test that generated attributes have correct properties.

test_upload_layout_creation()[source]

Test that layout is created with correct attributes.