Exemplo 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.apd.process_deceased_field', side_effect=ValueError)
    result = apd.parse_page_content(page)
    assert len(result) == 6
Exemplo n.º 2
0
def test_parse_page_content_00(filename, expected):
    """Ensure information are properly extracted from the content detail page.
           Don't compare notes if parsed from details page."""
    page_fd = TEST_DATA_DIR / filename
    page = page_fd.read_text()
    actual = apd.parse_page_content(page)
    if 'Notes' in actual and 'Notes' not in expected:
        del actual['Notes']
    assert actual == expected
Exemplo n.º 3
0
def test_parse_page_content_03():
    """Ensure a missing case number raises an exception."""
    with pytest.raises(ValueError):
        apd.parse_page_content('The is no case number here.')
Exemplo n.º 4
0
def test_parse_page_content_02(mocker):
    """Ensure a log entry is created if there is no deceased field."""
    result = apd.parse_page_content('Case: 01-2345678')
    assert result