Esempio n. 1
0
def test_parse_page_content_01(mocker):
    """Ensure a `process_deceased_field` exception is caught and does not propagate."""
    page_fd = TEST_DATA_DIR / 'traffic-fatality-2-3'
    page = page_fd.read_text()
    mocker.patch('scrapd.core.person.process_deceased_field', side_effect=ValueError)
    result, err = parsing.parse_page_content(page)
    if 'Deceased' in result:
        del result['Deceased']
    assert len(result) == 6
Esempio n. 2
0
def test_parse_page_content_03():
    """Ensure a missing case number raises an exception."""
    with pytest.raises(ValueError):
        parsing.parse_page_content('The is no case number here.')
Esempio n. 3
0
def test_parse_page_content_02(mocker):
    """Ensure a log entry is created if there is no deceased field."""
    result, err = parsing.parse_page_content('Case: 01-2345678')
    assert result
Esempio n. 4
0
def test_extract_deceased_field_from_page(page, start, end):
    page_text = load_test_page(page)
    parsed_content, _ = parsing.parse_page_content(page_text)
    deceased = parsed_content[Fields.DECEASED]
    assert deceased[0].startswith(start)
    assert deceased[-1].endswith(end)
Esempio n. 5
0
def test_parse_notes_field(page, start, end):
    page_text = load_test_page(page)
    parsed_content, r = parsing.parse_page_content(page_text)
    notes = parsed_content[Fields.NOTES]
    assert notes.startswith(start)
    assert notes.endswith(end)