Getting paint on the magnet is not a problem, it will adhere just as well.
However, as mentioned before, if two painted magnets are in direct contact with eachother, the paint will be rubbed off over time. This happens even quicker when the magnets form a rotating joint together, like for example on the tank turret.
I would spray the turret and the tank hull separately. Give the turret a good spray from the top and bottom. When painting, you only need to pay more attention to the top of the turret.
I don't know how you would spray the inside of the turret, and generally I don't think it is necessary.