On the surface, the idea has merit. Why should we allow someone to vote for our political leaders if they do not know basic facts about our political system. That the president and the Supreme Court do not MAKE laws. That it is Congress who is charged with producing a budget. That the Constitution actually CAN be changed. That just because the Supreme Court strikes down a law doesn't mean that Congress can't pass a modified law on the same subject. Etc.
However, we are human and humans cheat, lie and steal for personal gain. The test would be used for someone's political gain at some point. There is no way to guard against that.
The best way to get the best possible politicians is to educate our citizens from an early age on the political process, the laws, the history of our country and the Constitution, then clear the way for everyone to vote. The higher a percentage of eligible voters who actually vote, the more likely the right candidates will filter into our system.