picogl.tests.test_vertex_buffer_group

Unit tests for the VertexBufferGroup 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.gpu.buffers.vertex.legacy.VertexBufferGroup class, which manages legacy OpenGL vertex buffer objects and mimics VAO functionality.

The tests cover:

  • Object initialization and setup

  • VBO management and attribute configuration

  • EBO (Element Buffer Object) management

  • Layout descriptor configuration

  • Drawing operations with various modes

  • Buffer cleanup and memory management

  • Error handling and edge cases

  • Legacy client state management

Dependencies:
  • unittest (standard library)

  • unittest.mock.MagicMock for OpenGL function mocking

  • numpy for test data

  • picogl.gpu.buffers.vertex.legacy.VertexBufferGroup

  • picogl.buffers.attributes.LayoutDescriptor

To run the tests:

python -m unittest picogl.tests.test_vertex_buffer_group

Classes

TestVertexBufferGroup

Test cases for VertexBufferGroup class.

Module Contents

class picogl.tests.test_vertex_buffer_group.TestVertexBufferGroup(methodName='runTest')[source]

Bases: unittest.TestCase

Test cases for VertexBufferGroup class.

setUp()[source]

Set up test fixtures before each test method.

tearDown()[source]

Clean up after each test method.

test_initialization()[source]

Test VertexBufferGroup initialization.

test_add_vbo_object()[source]

Test add_vbo_object method for VBO management.

test_get_vbo_object()[source]

Test get_vbo_object method for VBO retrieval.

test_index_count_property()[source]

Test index_count property.

test_add_vbo()[source]

Test add_vbo method with different buffer types.

test_add_vbo_with_custom_parameters()[source]

Test add_vbo method with custom parameters.

test_add_vbo_invalid_parameters()[source]

Test add_vbo method with invalid parameters.

test_add_ebo()[source]

Test add_ebo method.

test_get_buffer_class()[source]

Test get_buffer_class method.

test_draw_with_arrays()[source]

Test draw method with vertex arrays.

test_draw_with_auto_index_count()[source]

Test draw method with automatic index count.

test_draw_elements()[source]

Test draw_elements method.

test_draw_elements_without_ebo()[source]

Test draw_elements method without EBO raises error.

test_draw_elements_with_auto_count()[source]

Test draw_elements method with automatic count.

test_set_layout()[source]

Test set_layout method.

test_bind_with_layout()[source]

Test bind method with layout.

test_bind_without_layout()[source]

Test bind method without layout.

test_bind_with_missing_vbo()[source]

Test bind method with missing VBO in layout.

test_unbind_with_layout()[source]

Test unbind method with layout.

test_unbind_without_layout()[source]

Test unbind method without layout.

test_delete()[source]

Test delete method.

test_delete_with_none_buffers()[source]

Test delete method with None buffers.

test_context_manager()[source]

Test that VertexBufferGroup can be used as a context manager.

test_error_handling_in_add_vbo()[source]

Test error handling in add_vbo method.

test_error_handling_in_bind()[source]

Test error handling in bind method.

test_bind_without_ebo()[source]

bind() skips EBO when geometry uses glDrawArrays only.

test_bind_legacy_buffer_roles()[source]

bind() resolves pointer method names and VertexBufferRole attributes.

test_bind_uses_vbo_handle()[source]

bind() passes VBO handle to glBindBuffer, not the buffer object.

test_bind_resolves_role_from_attr_role()[source]

bind() uses AttributeSpec.role as the canonical buffer role.

test_bind_resolves_role_from_vbo_type()[source]

bind() resolves buffer role from AttributeSpec.vbo_type.

test_compat_properties_sync_named_vbos()[source]

vbo/cbo/nbo/ebo properties read and write named_vbos.

test_draw_elements_uses_layout_bind_only()[source]

draw_elements() relies on layout bind(), not per-VBO bind().

test_type_conversion_in_bind()[source]

Test type conversion handling in bind method.

test_repr_string()[source]

Test string representation of VertexBufferGroup.

test_vbo_classes_mapping()[source]

Test VBO classes mapping is correct.

test_resolve_client_states()[source]

_resolve_client_states() derives gl client states from layout roles.

test_legacy_client_states_integration()[source]

Test integration with legacy client states.