Ejemplo n.º 1
0
def test_sentence_rendered_jail2():
    p = vtr.Parser()
    cases = list(
        p.parse(u"""
b 1907/15
pg 33
c 1160
ad 11 Dec 1907
hd 12 Dec 1907
d Bob Williams
r W
v 360
l Broad st.
ao R. A. Burpee
w R. A. Burpee
p G
sr J ("that the Def be confined in the City Prison until Dec. 31st 1907 until 7 O clock P. M.")
""".splitlines()))
    case = cases[0]
    try:
        assert len(case['sentence_rendered']) == 1
    except KeyError:
        assert False, 'No sentence rendered found'
    sr = case['sentence_rendered'][0]
    assert sr['type'] == 'jail'
    assert sr['amount'] == 0.0
    assert sr['units'] == 'days'
    assert sr[
        'note'] == '"that the Def be confined in the City Prison until Dec. 31st 1907 until 7 O clock P. M."'
Ejemplo n.º 2
0
def test_multiple_cases():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1900/1
c 1
c 2
""".splitlines()))
    assert len(cases) == 2
Ejemplo n.º 3
0
def test_book():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1900/1
c 1
""".splitlines()))
    assert len(cases) == 1
    assert cases[0]['book'] == '1900/1'
Ejemplo n.º 4
0
def test_year_from_book():
    p = vtr.Parser()
    c = {
        'participants': [],
        'number': 1,
        'book': '1901/1',
    }
    p.prepare_case(c, 0)
    assert c['year'] == 1901
Ejemplo n.º 5
0
def test_multiple_cases_in_multiple_books():
    p = vtr.Parser()
    cases = p.parse(u"""
b 1900/1
c 1
b 1900/2
c 2
""".splitlines())
    assert len(list(cases)) == 2
Ejemplo n.º 6
0
def test_note():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1900/1
pg 170
c 172
n note 1
""".splitlines()))
    assert len(cases) == 1
    assert cases[0]['note'] == 'note 1'
Ejemplo n.º 7
0
def test_race_white():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 170
c 172
r w
""".splitlines()))
    case = cases[0]
    assert case['race'] == 'w'
Ejemplo n.º 8
0
def test_plea_nc():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 170
c 172
p nc
""".splitlines()))
    case = cases[0]
    assert case['plea'] == 'no contest'
Ejemplo n.º 9
0
def test_race_colored_upper():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 170
c 172
r C
""".splitlines()))
    case = cases[0]
    assert case['race'] == 'c'
Ejemplo n.º 10
0
def test_gender_female():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 170
c 172
g f
""".splitlines()))
    case = cases[0]
    assert case['gender'] == 'f'
Ejemplo n.º 11
0
def test_outcome_not_guilty():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 170
c 172
o ng
""".splitlines()))
    case = cases[0]
    assert case['outcome'] == 'not guilty'
Ejemplo n.º 12
0
def test_violation():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 119
c 21
v 123
""".splitlines()))
    case = cases[0]
    assert case['violation'] == '123'
Ejemplo n.º 13
0
def test_plea_guitly():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 170
c 172
p guitly
""".splitlines()))
    case = cases[0]
    assert case['plea'] == 'guilty'
Ejemplo n.º 14
0
def test_outcome_dismissed():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 170
c 172
o d
""".splitlines()))
    case = cases[0]
    assert case['outcome'] == 'dismissed'
Ejemplo n.º 15
0
def test_no_defendant():
    p = vtr.Parser()
    c = {
        'participants': [],
        'number': 1,
    }
    p.validate_case(c, 0)
    msgs = [e[-1] for e in p.errors]
    assert msgs
    assert 'No defendant' in msgs[0]
Ejemplo n.º 16
0
def test_year_from_arrest_date():
    p = vtr.Parser()
    c = {
        'participants': [],
        'number': 1,
        'book': '1901/1',
        'arrest_date': datetime.datetime(1902, 1, 1, 1, 1)
    }
    p.prepare_case(c, 0)
    assert c['year'] == 1902
Ejemplo n.º 17
0
def test_outcome_guilty_verbose():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 170
c 172
o guilty
""".splitlines()))
    case = cases[0]
    assert case['outcome'] == 'guilty'
Ejemplo n.º 18
0
def test_sentence_rendered_other_without_note():
    p = vtr.Parser()
    assert_raises(
        ValueError, list,
        p.parse(u"""
b 1902/6
pg 170
c 172
sr o
""".splitlines(),
                continueOnError=False))
Ejemplo n.º 19
0
def test_outcome_suspended_verbose():
    p = vtr.Parser()
    cases = list(
        p.parse(u"""
b 1902/6
pg 170
c 172
o suspended
""".splitlines()))
    case = cases[0]
    assert case['outcome'] == 'suspended'
Ejemplo n.º 20
0
def test_location():
    p = vtr.Parser()
    cases = list(
        p.parse(u"""
b 1902/6
pg 170
c 174
l College & River Streets
""".splitlines()))
    case = cases[0]
    assert case['location'] == 'College & River Streets'
Ejemplo n.º 21
0
def test_case_note():
    p = vtr.Parser()
    cases = list(
        p.parse(u"""
b 1902/6
pg 170
c 172
n this is a test case
""".splitlines()))
    case = cases[0]
    assert case['note'] == 'this is a test case'
Ejemplo n.º 22
0
def test_violation_note():
    p = vtr.Parser()
    cases = list(
        p.parse(u"""
b 1902/6
pg 119
c 21
v 123 (some additional info)
""".splitlines()))
    case = cases[0]
    assert case['violation'] == '123'
    assert case['violation_note'] == 'some additional info'
Ejemplo n.º 23
0
def test_defendant_vehicle():
    p = vtr.Parser()
    cases = list(
        p.parse(u"""
b 1902/6
pg 119
c 21
d Jerry Brown suffix=Jr.
dv abc 123
""".splitlines()))
    case = cases[0]
    assert case['vehicle'] == 'abc 123'
Ejemplo n.º 24
0
def test_dates():
    p = vtr.Parser()
    cases = list(
        p.parse(u"""
b 1902/6
pg 170
c 172
ad 30 Mar 1903
hd 01 Apr 1903
""".splitlines()))
    case = cases[0]
    assert case['arrest_date'] == datetime.datetime(1903, 3, 30)
    assert case['hearing_date'] == datetime.datetime(1903, 4, 1)
Ejemplo n.º 25
0
def test_sentence_rendered_labor_months():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 170
c 172
sr 5 M
""".splitlines()))
    case = cases[0]
    try:
        assert len(case['sentence_rendered']) == 1
    except KeyError:
        assert False, 'No sentence rendered found'
    sr = case['sentence_rendered'][0]
    assert sr['type'] == 'labor'
    assert sr['amount'] == 5.0
    assert sr['units'] == 'months'
Ejemplo n.º 26
0
def test_arresting_officer():
    p = vtr.Parser()
    cases = list(
        p.parse(u"""
b 1902/6
pg 170
c 172
ao Hamilton
""".splitlines()))
    case = cases[0]
    assert len(case['participants']) == 1
    part = case['participants'][0]
    assert part['role'] == 'arresting officer'
    assert part['full_name'] == 'Hamilton'
    assert part['first_name'] == ''
    assert part['middle_name'] == ''
    assert part['last_name'] == 'Hamilton'
Ejemplo n.º 27
0
def test_other_person_simple():
    p = vtr.Parser()
    cases = list(
        p.parse(u"""
b 1902/6
pg 170
c 172
op Charley Thomas
""".splitlines()))
    case = cases[0]
    assert len(case['participants']) == 1
    part = case['participants'][0]
    assert part['role'] == 'other'
    assert part['full_name'] == 'Charley Thomas'
    assert part['first_name'] == 'Charley'
    assert part['middle_name'] == ''
    assert part['last_name'] == 'Thomas'
Ejemplo n.º 28
0
def test_sentence_served_remitted():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 170
c 172
ss 5 R
""".splitlines()))
    case = cases[0]
    try:
        assert len(case['sentence_served']) == 1
    except KeyError:
        assert False, 'No sentence served found'
    ss = case['sentence_served'][0]
    assert ss['type'] == 'remitted'
    assert ss['amount'] == 5.0
    assert ss['units'] == '$'
Ejemplo n.º 29
0
def test_defendant_two_middle_names():
    p = vtr.Parser()
    cases = list(
        p.parse(u"""
b 1902/6
pg 170
c 172
d Charley MidA MidB Thomas
""".splitlines()))
    case = cases[0]
    assert len(case['participants']) == 1
    part = case['participants'][0]
    assert part['role'] == 'defendant'
    assert part['full_name'] == 'Charley MidA MidB Thomas'
    assert part['first_name'] == 'Charley'
    assert part['middle_name'] == 'MidA MidB'
    assert part['last_name'] == 'Thomas'
Ejemplo n.º 30
0
def test_sentence_contempt_type_labor():
    p = vtr.Parser()
    cases = list(p.parse(u"""
b 1902/6
pg 170
c 172
sc 5 W
""".splitlines()))
    case = cases[0]
    try:
        assert len(case['sentence_contempt']) == 1
    except KeyError:
        assert False, 'No sentence contempt found'
    sc = case['sentence_contempt'][0]
    assert sc['type'] == 'labor'
    assert sc['amount'] == 5.0
    assert sc['units'] == 'days'