The CPS must either have your consent or a court order to force you take a drug test.
However if your children were taken away and you're trying to get the children back the CPS and court can require you as the parents or parent to take and pass a drug test before they allow you to have custody of your children back.
So if you do not do drugs and have had your children taken away then taking a drug test would be the best thing to do because if you don't take the drug test then that makes you seem like you're guilty of doing drugs and then they won't give your children back.
If you drugs though and fail the drug test then you will likely permanently lose custody of your children and rightfully so.