def test_get_children_fails(self, particle): """Test that get_children fails if the parent isn't in the tree""" event = Event(particle) child1 = Particle(particle_id=Particle.Type.electron, vertex=[100, 200, -500], direction=[0, 0, 1], energy=1e9, interaction_model=Interaction) with pytest.raises(ValueError): event.get_children(child1)
def test_get_children(self, particle): """Test the ability to retrieve children of a particle""" event = Event(particle) child1 = Particle(particle_id=Particle.Type.electron, vertex=[100, 200, -500], direction=[0, 0, 1], energy=1e9, interaction_model=Interaction) child2 = Particle(particle_id=Particle.Type.positron, vertex=[100, 200, -500], direction=[0, 0, 1], energy=1e9, interaction_model=Interaction) event.add_children(particle, [child1, child2]) expected_children = [child1, child2] for child in event.get_children(particle): assert child in expected_children expected_children.remove(child) assert expected_children == [] assert event.get_children(child1) == []