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",
    }
Exemplo n.º 2
0
def test_simple_vote_event():
    ve = toy_vote_event()
    ve.set_count("yes", 2)
    ve.yes("James")
    ve.no("Paul")
    ve.vote("abstain", "Thom")

    assert len(ve.votes) == 3
    assert len(ve.counts) == 1
    assert get_pseudo_id(ve.organization) == {"classification": "legislature"}
    assert get_pseudo_id(ve.votes[0]["voter_id"]) == {"name": "James"}
    assert get_pseudo_id(ve.votes[1]["voter_id"]) == {"name": "Paul"}
    assert get_pseudo_id(ve.votes[2]["voter_id"]) == {"name": "Thom"}
    assert ve.bill is None

    ve.validate()
    assert "we get here"
Exemplo n.º 3
0
def test_set_bill_pseudo_id():
    ve = toy_vote_event()
    ve.set_bill("HB 1", chamber="lower")
    assert get_pseudo_id(ve.bill) == {
        "identifier": "HB 1",
        "from_organization__classification": "lower",
        "legislative_session__identifier": "2009",
    }
def test_person_add_party():
    p = Person("Groot")
    p.add_party("Green")
    p._related[0].validate()
    assert get_pseudo_id(p._related[0].organization_id) == {
        "name": "Green",
        "classification": "party",
    }
def test_person_add_term():
    p = Person("Eternal")
    p.add_term("eternal", "council", start_date="0001", end_date="9999")
    p._related[0].validate()
    assert get_pseudo_id(p._related[0].organization_id) == {
        "classification": "council"
    }
    assert p._related[0].start_date == "0001"
    assert p._related[0].end_date == "9999"
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"
Exemplo n.º 7
0
def test_vote_event_org_chamber():
    ve = VoteEvent(
        legislative_session="2009",
        motion_text="passage of the bill",
        start_date="2009-01-07",
        result="pass",
        classification="passage",
        chamber="upper",
    )
    assert get_pseudo_id(ve.organization) == {"classification": "upper"}
Exemplo n.º 8
0
def test_vote_event_org_dict():
    odict = {"name": "Random Committee", "classification": "committee"}
    ve = VoteEvent(
        legislative_session="2009",
        motion_text="passage of the bill",
        start_date="2009-01-07",
        result="pass",
        classification="passage",
        organization=odict,
    )
    assert get_pseudo_id(ve.organization) == odict
def test_person_add_membership_name():
    p = Person("Leonardo DiCaprio")
    p.add_membership("Academy of Motion Picture Arts and Sciences",
                     role="winner",
                     start_date="2016")
    p._related[0].validate()
    assert get_pseudo_id(p._related[0].organization_id) == {
        "name": "Academy of Motion Picture Arts and Sciences"
    }
    assert p._related[0].person_id == p._id
    assert p._related[0].role == "winner"
    assert p._related[0].start_date == "2016"
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_committee_add_member_name():
    c = Organization("Defense", classification="committee")
    c.add_member("John Adams")
    assert get_pseudo_id(c._related[0].person_id) == {"name": "John Adams"}
    assert c._related[0].organization_id == c._id
    assert c._related[0].role == "member"