How many days before you period is due can you take a pregnancy test?

Period is due in 7 days