How can i modify FASTA headers in a multi fasta file using BioPython SeqIO
You're very close, but unfortunately for legacy reasons this aspect of the Biopython parser is not very intuitive. The key point is the .id is anything up until the first white space character. One day I hope the .description and .id attributes are replaced by a single attribute like .header. Anyway, here is a solution for your case:

from Bio import SeqIO

to_add = "TEST~~~TEST~~~"

with open("out.fa", "w") as outputs:
    for r in SeqIO.parse("in.fa", "fasta"):
        r.id = (to_add + r.description).replace(" ", "_")
        r.description = r.id
        SeqIO.write(r, outputs, "fasta")


Output on your sample input:

&gt;TEST~~~TEST~~~AAA_a_aa
ATGATG
&gt;TEST~~~TEST~~~BBB_b_bb
GACGAC
&gt;TEST~~~TEST~~~CCC_c_cc
TTGTTG