コード例 #1
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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"
コード例 #2
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #3
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #4
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #5
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #6
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #7
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #8
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #9
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #10
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #11
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #12
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #13
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #14
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #15
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #16
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #17
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #18
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #19
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #20
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #21
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #22
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #23
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #24
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #25
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #26
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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]
コード例 #27
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #28
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #29
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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
コード例 #30
0
ファイル: test_client.py プロジェクト: russbiggs/legistar
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