If legislated properly, that is not how it works.
Your driver's license, or a pilot's license, or a law degree, etc., all have independent criteria that is effectively non-political. You can be a raging Commie, bomb-adjacent anarchist, or tall-and-square bleeds-red-white-and-blue right-wing Navy admiral. But something like a driving license test is not about any of that. It is about the knowledge level and demonstrated ability to command a road vehicle safely in concert with thousands of other drivers.
Similarly, a political candidate's "license" should test the demonstrated knowledge of the house of government they are a candidate for, and the ability to understand and follow the current operating protocols of that house. The "road rules" if you will of government. It does not play, and should not be allowed to play, on political leaning either way. If you are a seig-heiling fascist and you pass the test, OK, you can stand. If you are a bleeding-heart liberal and you fail the test, you don't get to be a candidate. And if they fail, maybe have a time period before they can try again? Next election?
You can then legislate that if a member of that house breaches the licensing standard they supposedly passed, they can be liable for sanctions by the house. With a standard to compare them to, judgement is much easier. "Here's the standard you know you were supposed to uphold. You have not. Sanctions will follow." My suggested first level of sanction is loss of standing as a candidate come the next election cycle, just like if they failed the test. A more severe sanction would be expulsion from that house.
None of this would prevent the deplorable display of recalcitrance such as EmptyG displayed at the SOTU address last week. But it does highlight that they are failing to meet the Congressional member standard, which she clearly would have done had there been a standard, she would be facing major penalties. Not that it would worry her - she will always claim she was the victim. But too bad. Tell it to the hand.