def test_multiple_parties(): p = Person( id=VALID_PERSON_ID, name="Tony Tigre", party=[Party(name="Democratic")], roles=[], ) with pytest.raises(ValidationError): # can't have two active major parties p.party = [Party(name="Democratic"), Party(name="Republican")] # can be in multiple parties as long as one is non-major p.party = [Party(name="Democratic"), Party(name="Green")] # or if one is obsolete p.party = [Party(name="Democratic", end_date="2010"), Party(name="Republican")]
def test_party_on_person(): p = Person( id=VALID_PERSON_ID, name="Tony Tigre", party=[Party(name="Democratic")], roles=[], ) with pytest.raises(ValidationError): # no such party p.party = [Party(name="Vampire")]
def test_party_required_on_legislator(): p = Person( id=VALID_PERSON_ID, name="Tony Tigre", party=[Party(name="Democratic")], roles=[ Role(type=RoleType.UPPER, district=1, jurisdiction=VALID_JURISDICTION_ID) ], ) with pytest.raises(ValidationError): # no party! p.party = []