Hey there!
This is just not how signals work in Godot, you have to connect them to a script through the "Node" tab that is right next to the Inspector. When you do so, a new function will be created on your script. It should look something like:
_on_AnimationPlayer_animation_finished(anim_name):
I'm not sure if this is how the name looks like by default... Anyways, this function (that may have any name you wish as long as you connect it from the Node tab) will be called every time an animation finishes.
So, taking your code as an example... It should look like this, if correctly used the function.
_on_cool_animation_thing_finished(anim_name):
if anim_name == "name":
print("test")
Hope I helped you!
Basicly the function is automatically called once the even triggers.
If you want to learn more about signals, check this page on the docs.