Exemplo n.º 1
0
def test_matter_attachment_file():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/matters/1/attachments/1/file",
        body=b"\xff",
        status=200,
    )
    api = Legistar("test")
    resp = api.matter_attachment_file(1, 1)
    assert resp == b"\xff"
Exemplo n.º 2
0
def test_all_event_item():
    responses.add(
        responses.GET,
        f"https://webapi.legistar.com/v1/test/events/4/eventitems?agendanote=1&minutesnote=1&attachments=1",
        json=[event_item_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_event_items(4, agenda_note=1, minutes_note=1, attachments=1)
    event_item = event_item_from_dict(event_item_json)
    assert resp == [event_item]
Exemplo n.º 3
0
def test_code_section():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/codesections/42",
        json=code_section_json,
        status=200,
    )
    api = Legistar("test")
    resp = api.code_section(42)
    code_section = code_section_from_dict(code_section_json)
    assert resp == code_section
Exemplo n.º 4
0
def test_all_code_sections():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/codesections",
        json=[code_section_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_code_sections()
    code_section = code_section_from_dict(code_section_json)
    assert resp == [code_section]
Exemplo n.º 5
0
def test_body_type():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/bodytypes/1",
        json=body_type_json,
        status=200,
    )
    api = Legistar("test")
    resp = api.body_type(1)
    body_type = body_type_from_dict(body_type_json)
    assert resp == body_type
Exemplo n.º 6
0
def test_all_body_types():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/bodytypes",
        json=[body_type_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_body_types()
    body_type = body_type_from_dict(body_type_json)
    assert resp == [body_type]
Exemplo n.º 7
0
def test_all_vote_types():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/votetypes",
        json=[vote_type_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_vote_types()
    vote_type = vote_type_from_dict(vote_type_json)
    assert resp == [vote_type]
Exemplo n.º 8
0
def test_vote_type():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/votetypes/1",
        json=vote_type_json,
        status=200,
    )
    api = Legistar("test")
    resp = api.vote_type(1)
    vote_type = vote_type_from_dict(vote_type_json)
    assert resp == vote_type
Exemplo n.º 9
0
def test_vote_by_event_item():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/eventitems/8/votes/1",
        json=vote_json,
        status=200,
    )
    api = Legistar("test")
    resp = api.vote_by_event_item(8, 1)
    vote = vote_from_dict(vote_json)
    assert resp == vote
Exemplo n.º 10
0
def test_all_votes_by_person():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/persons/1/votes",
        json=[vote_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_votes_by_person(1)
    vote = vote_from_dict(vote_json)
    assert resp == [vote]
Exemplo n.º 11
0
def test_all_roll_calls_by_person():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/persons/4/rollcalls",
        json=[roll_call_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_roll_calls_by_person(4)
    roll_call = roll_call_from_dict(roll_call_json)
    assert resp == [roll_call]
Exemplo n.º 12
0
def test_roll_call_by_event_item():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/eventitems/8/rollcalls/1",
        json=roll_call_json,
        status=200,
    )
    api = Legistar("test")
    resp = api.roll_call_by_event_item(8, 1)
    roll_call = roll_call_from_dict(roll_call_json)
    assert resp == roll_call
Exemplo n.º 13
0
def test_person():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/persons/1",
        json=person_json,
        status=200,
    )
    api = Legistar("test")
    resp = api.person(1)
    person = person_from_dict(person_json)
    assert resp == person
Exemplo n.º 14
0
def test_all_office_records_by_body():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/bodies/11/officerecords",
        json=[office_record_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_office_records_by_body(11)
    office_record = office_record_from_dict(office_record_json)
    assert resp == [office_record]
Exemplo n.º 15
0
def test_all_events():
    responses.add(
        responses.GET,
        f"https://webapi.legistar.com/v1/test/events",
        json=[event_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_events()
    event = event_from_dict(event_json)
    assert resp == [event]
Exemplo n.º 16
0
def test_matter_status():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/matterstatuses/1",
        json=matter_status_json,
        status=200,
    )
    api = Legistar("test")
    resp = api.matter_status(1)
    matter_status = matter_status_from_dict(matter_status_json)
    assert resp == matter_status
Exemplo n.º 17
0
def test_office_record():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/officerecords/1",
        json=office_record_json,
        status=200,
    )
    api = Legistar("test")
    resp = api.office_record(1)
    office_record = office_record_from_dict(office_record_json)
    assert resp == office_record
Exemplo n.º 18
0
def test_all_matter_relations():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/matters/3/relations",
        json=[matter_relation_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_matter_relations(3)
    matter_relation = matter_relation_from_dict(matter_relation_json)
    assert resp == [matter_relation]
Exemplo n.º 19
0
def test_all_matter_sponsors():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/matters/4/sponsors",
        json=[matter_sponsor_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_matter_sponsors(4)
    matter_sponsor = matter_sponsor_from_dict(matter_sponsor_json)
    assert resp == [matter_sponsor]
Exemplo n.º 20
0
def test_matter_relation():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/matters/3/relations/1",
        json=matter_relation_json,
        status=200,
    )
    api = Legistar("test")
    resp = api.matter_relation(3, 1)
    matter_relation = matter_relation_from_dict(matter_relation_json)
    assert resp == matter_relation
Exemplo n.º 21
0
def test_all_actions():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/actions",
        json=[action_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_actions()
    action = action_from_dict(action_json)
    assert resp == [action]
Exemplo n.º 22
0
def test_all_matter_indexes():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/matterindexes",
        json=[matter_index_json],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_matter_indexes()
    matter_index = matter_index_from_dict(matter_index_json)
    assert resp == [matter_index]
Exemplo n.º 23
0
def test_matter_history(agenda_note, minutes_note, result):
    responses.add(
        responses.GET,
        f"https://webapi.legistar.com/v1/test/matters/1/histories/1?agendanote={agenda_note}&minutesnote={minutes_note}",
        json=result,
        status=200,
    )
    api = Legistar("test")
    resp = api.matter_history(1, 1, agenda_note=agenda_note, minutes_note=minutes_note)
    matter_history = matter_history_from_dict(result)
    assert resp == matter_history
Exemplo n.º 24
0
def test_matter_attachment():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/matters/1/attachments/1",
        json=matter_attachment_json,
        status=200,
    )
    api = Legistar("test")
    resp = api.matter_attachment(1, 1)
    matter_attachment = matter_attachment_from_dict(matter_attachment_json)
    assert resp == matter_attachment
Exemplo n.º 25
0
def test_index():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/indexes/1",
        json=index_json,
        status=200,
    )
    api = Legistar("test")
    resp = api.index(1)
    index = index_from_dict(index_json)
    assert resp == index
Exemplo n.º 26
0
def test_all_matter_texts_version_by_matter():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/matters/4/versions",
        json=[{"Key": "sample string 1", "Value": "sample string 2"}],
        status=200,
    )
    api = Legistar("test")
    resp = api.all_matter_texts_version_by_matter(4)
    matter_text_version = matter_text_version_from_dict(
        {"Key": "sample string 1", "Value": "sample string 2"}
    )
    assert resp == [matter_text_version]
Exemplo n.º 27
0
def test_event_item(agenda_note, minutes_note, attachments, result):
    responses.add(
        responses.GET,
        f"https://webapi.legistar.com/v1/test/events/4/eventitems/1?agendanote={agenda_note}&minutesnote={minutes_note}&attachments={attachments}",
        json=result,
        status=200,
    )
    api = Legistar("test")
    resp = api.event_item(
        4,
        1,
        agenda_note=agenda_note,
        minutes_note=minutes_note,
        attachments=attachments,
    )
    event_item = event_item_from_dict(result)
    assert resp == event_item
Exemplo n.º 28
0
def test_event_dates_by_body():
    responses.add(
        responses.GET,
        "https://webapi.legistar.com/v1/test/eventdates/1?futuredatesonly=True",
        json=["2019-08-08T19:54:05.3051663-04:00", "2019-08-08T19:54:05.3051663-04:00"],
        status=200,
    )
    api = Legistar("test")
    resp = api.event_dates_by_body(1)
    dates = [
        from_datetime(item)
        for item in [
            "2019-08-08T19:54:05.3051663-04:00",
            "2019-08-08T19:54:05.3051663-04:00",
        ]
    ]
    assert resp == dates
Exemplo n.º 29
0
def test_event(event_items, agenda_note, minutes_note, event_item_attachments, result):
    responses.add(
        responses.GET,
        f"https://webapi.legistar.com/v1/test/events/1?eventitems={event_items}&agendanote={agenda_note}&minutesnote={minutes_note}&eventitemattachments={event_item_attachments}",
        json=result,
        status=200,
    )
    api = Legistar("test")
    resp = api.event(
        1,
        event_items=event_items,
        agenda_note=agenda_note,
        minutes_note=minutes_note,
        event_item_attachments=event_item_attachments,
    )
    event = event_from_dict(result)
    assert resp == event
Exemplo n.º 30
0
def test_build_url():
    api = Legistar("test")
    url = api._build_url("body", 42)
    expected = "https://webapi.legistar.com/v1/test/body/42"
    assert url == expected