Beispiel #1
0
def test_addition_to_system__entity_first(world, null_system):
    entity = world.create_entity(NullComponent())
    world._flush_component_updates()
    world.add_system(null_system, 0)
    assert entity in null_system.entities['null']
    assert len(null_system.entries) == 1
    assert null_system.entries[0] == (['null'], entity)
Beispiel #2
0
def test_add_component(world, entity):
    component = NullComponent()
    entity[NullComponent] = component
    assert entity in world._addition_pool
    with pytest.raises(KeyError):
        entity[NullComponent]

    world._flush_component_updates()
    assert entity not in world._addition_pool
    assert entity[NullComponent] is component
Beispiel #3
0
def test_remove_system(world, null_system):
    entity = world.create_entity(NullComponent())
    world._flush_component_updates()
    world.add_system(null_system, 0)

    world.remove_system(NullSystem)
    assert null_system.entities['null'] == set()
    assert len(null_system.exits) == 1
    assert null_system.entries[0] == (['null'], entity)
    assert world.systems == {}
    assert not world.has_system(NullSystem)
Beispiel #4
0
def test_proxying_system__proxy_type(world):
    class NonBareTypeProxy(ProxyingNullSystem):
        proxies = {
            'null_proxy': ProxyType(NullComponent),
        }

    system = NonBareTypeProxy()
    world.add_system(system, 0)
    entity = world.create_entity(NullComponent())
    world._flush_component_updates()
    assert entity in system.entities["null"]
    assert len(system.entries) == 1
    assert system.entries[0] == (['null'], entity)
Beispiel #5
0
def test_remove_component(world, entity):
    component = NullComponent()
    entity[NullComponent] = component
    world._flush_component_updates()

    del entity[NullComponent]
    assert entity in world._removal_pool
    assert entity[NullComponent] is component

    world._flush_component_updates()
    assert entity not in world._removal_pool
    with pytest.raises(KeyError):
        entity[NullComponent]
Beispiel #6
0
def test_bare_system(bare_null_world, bare_null_system):
    entity = bare_null_world.create_entity(NullComponent())
    bare_null_world._flush_component_updates()
    assert entity in bare_null_system.entities["null"]
    assert len(bare_null_system.entries) == 1
    assert bare_null_system.entries[0] == (['null'], entity)