Example #1
0
def test_merge_committees_members():
    comdir = CommitteeDir(abbr="wa", directory=TEST_DATA_PATH / "committees")
    id_one = "ocd-organization/00000000-0000-0000-0000-000000000001"
    id_two = "ocd-organization/00000000-0000-0000-0000-000000000002"
    person_id = "ocd-person/00000000-0000-0000-0000-000000000002"
    c1 = Committee(
        id=id_one,
        jurisdiction=JURISDICTION_ID,
        chamber="upper",
        name="Education",
        members=[
            Membership(name="Amy", role="chair"),
            Membership(name="Bo", role="chair"),
        ],
    )
    c2 = Committee(
        id=id_two,
        jurisdiction=JURISDICTION_ID,
        chamber="upper",
        name="Education & Children",
        members=[
            Membership(name="Amy", role="chair", person_id=person_id),
            Membership(name="Charlize", role="member"),
        ],
    )
    merged = comdir.merge_committees(c1, c2)
    assert merged.members == [
        Membership(name="Amy", role="chair", person_id=person_id),
        Membership(name="Bo", role="chair"),
        Membership(name="Charlize", role="member"),
    ]
Example #2
0
def test_merge_committees_links():
    comdir = CommitteeDir(abbr="wa", directory=TEST_DATA_PATH / "committees")
    id_one = "ocd-organization/00000000-0000-0000-0000-000000000001"
    id_two = "ocd-organization/00000000-0000-0000-0000-000000000002"
    c1 = Committee(
        id=id_one,
        jurisdiction=JURISDICTION_ID,
        chamber="upper",
        name="Education",
        links=[
            Link(url="https://example.com/1"),
            Link(url="https://example.com/2"),
        ],
        members=[Membership(name="Someone", role="member")],
    )
    c2 = Committee(
        id=id_two,
        jurisdiction=JURISDICTION_ID,
        chamber="upper",
        name="Education & Children",
        links=[
            Link(url="https://example.com/1", note="first"),
            Link(url="https://example.com/3"),
        ],
        members=[Membership(name="Someone", role="member")],
    )
    merged = comdir.merge_committees(c1, c2)
    assert merged.links == [
        Link(url="https://example.com/1", note="first"),
        Link(url="https://example.com/2"),
        Link(url="https://example.com/3"),
    ]
Example #3
0
def test_merge_committees_invalid():
    comdir = CommitteeDir(abbr="wa", directory=TEST_DATA_PATH / "committees")

    id_one = "ocd-organization/00000000-0000-0000-0000-000000000001"
    id_two = "ocd-organization/00000000-0000-0000-0000-000000000002"
    c1 = Committee(
        id=id_one,
        jurisdiction=JURISDICTION_ID,
        chamber="upper",
        name="Education",
        members=[Membership(name="Someone", role="member")],
    )
    c2 = Committee(
        id=id_two,
        jurisdiction=JURISDICTION_ID,
        chamber="lower",
        name="Education & Children",
        members=[Membership(name="Someone", role="member")],
    )
    with pytest.raises(ValueError):
        comdir.merge_committees(c1, c2)
Example #4
0
def test_merge_committees_name():
    comdir = CommitteeDir(abbr="wa", directory=TEST_DATA_PATH / "committees")
    id_one = "ocd-organization/00000000-0000-0000-0000-000000000001"
    id_two = "ocd-organization/00000000-0000-0000-0000-000000000002"
    c1 = Committee(
        id=id_one,
        jurisdiction=JURISDICTION_ID,
        chamber="upper",
        name="Education",
        members=[Membership(name="Someone", role="member")],
    )
    c2 = Committee(
        id=id_two,
        jurisdiction=JURISDICTION_ID,
        chamber="upper",
        name="Education & Children",
        members=[Membership(name="Someone", role="member")],
    )
    merged = comdir.merge_committees(c1, c2)
    assert merged.id == c1.id
    assert merged.name == c2.name