def test_legislator_related_party():
    leg = Person("John Adams", party="Democratic-Republican")
    leg.pre_save("jurisdiction-id")

    # a party membership
    assert len(leg._related) == 1
    assert leg._related[0].person_id == leg._id
    assert get_pseudo_id(leg._related[0].organization_id) == {
        "classification": "party",
        "name": "Democratic-Republican",
    }
    assert leg._related[0].role == "member"
def test_legislator_related_district():
    leg = Person("John Adams", district="1", primary_org="legislature")
    leg.pre_save("jurisdiction-id")

    assert len(leg._related) == 1
    assert leg._related[0].person_id == leg._id
    assert get_pseudo_id(leg._related[0].organization_id) == {
        "classification": "legislature"
    }
    assert get_pseudo_id(leg._related[0].post_id) == {
        "organization__classification": "legislature",
        "label": "1",
    }
def test_legislator_related_chamber_district_role():
    leg = Person("John Adams",
                 district="1",
                 primary_org="lower",
                 role="Speaker")
    leg.pre_save("jurisdiction-id")

    assert len(leg._related) == 1
    assert leg._related[0].person_id == leg._id
    assert get_pseudo_id(leg._related[0].organization_id) == {
        "classification": "lower"
    }
    assert get_pseudo_id(leg._related[0].post_id) == {
        "organization__classification": "lower",
        "label": "1",
        "role": "Speaker",
    }
    assert leg._related[0].role == "Speaker"