Pilots in the US are at "risk" of being required to provide bodily fluid samples at absolutely any time they are on the ground and on duty. It can be at the beginning of a trip, as soon as you step on company property. It could be anywhere along the flight where you might land. It could be when you arrive at your final destination. It could even be all three locations! Of course, any crew member can report any other if they see dangerous behavior, even if not on duty! The only difference in the cockpit crew and the cabin attendants during a crash is that the former arrive at the crash site a few micro seconds earlier than the latter.
There are other rules covering how much time since your last alcohol consumption. Some pilots even avoided eating anything with poppy seeds in it; supposedly shows up as drugs in some tests.
I am a bit confused about that linked story. I quote:
[The pilot], who has not been named, was arrested and subsequently bailed pending further inquiries. [emphasis added]
I didn't know that American Airlines gave parachutes to their pilots!!
If/when I next travel by air, I may not choose AA!