From 23887396dd9f1fe44f652309c1c76b0c16fb9184 Mon Sep 17 00:00:00 2001 From: Noah Hall Date: Fri, 9 Apr 2021 17:58:40 -0400 Subject: [PATCH] update OffenseRecordRow description regex It now matches the regex in OffenseRecordRowWithNumber. --- ciprs_reader/parser/section/offense.py | 2 +- tests/parsers/test_offense.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ciprs_reader/parser/section/offense.py b/ciprs_reader/parser/section/offense.py index 3141a2a..3ac4a08 100644 --- a/ciprs_reader/parser/section/offense.py +++ b/ciprs_reader/parser/section/offense.py @@ -50,7 +50,7 @@ class OffenseRecordRow(OffenseSectionParser): """ # pylint: disable=line-too-long - pattern = r"\s*(?P\w+)\s+(?P[\w \-\(\)]+)[ ]{2,}(?P\w+)[ ]{2,}(?P[\w. \-\(\)]+)" + pattern = r"\s*(?P\w+)\s+(?P.+)[ ]{2,}(?P\w+)[ ]{2,}(?P[\w. \-\(\)]+)" def is_enabled(self): in_offense_section = super().is_enabled() diff --git a/tests/parsers/test_offense.py b/tests/parsers/test_offense.py index 338bb26..7a42b0f 100644 --- a/tests/parsers/test_offense.py +++ b/tests/parsers/test_offense.py @@ -39,6 +39,13 @@ def test_offense_record_arrainged(report, state): assert matches["law"] == "G.S. 20-141(B)" +def test_offense_record_with_slashes(report, state): + string = "CONVICTED CITY/TOWN VIOLATION (I) INFRACTION LOCAL ORDINANCE" + matches = offense.OffenseRecordRow(report, state).match(string) + assert matches is not None, "Regex match failed" + assert matches["desc"] == "CITY/TOWN VIOLATION (I)" + + def test_offense_record_convicted(report, state): string = "CONVICTED IMPROPER EQUIP - SPEEDOMETER INFRACTION G.S. 20-123.2" # noqa matches = offense.OffenseRecordRow(report, state).match(string)