forked from ecprice/newsdiffs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ecprice#49 from carlgieringer/master
Fix NYTParser for new article format
- Loading branch information
Showing
6 changed files
with
6,801 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,9 @@ pip-log.txt | |
|
||
newsdiffs.db | ||
database_settings.py | ||
|
||
/.pytest_cache/ | ||
# pyenv | ||
/.python-version | ||
# IntelliJ | ||
/.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from mock import patch | ||
|
||
from nyt import NYTParser | ||
|
||
|
||
@patch('parsers.baseparser.grab_url') | ||
def test_old_format(mock_grab_url): | ||
from test_nyt_data import HTML_OLD_FORMAT | ||
mock_grab_url.return_value = HTML_OLD_FORMAT | ||
parser = NYTParser('https://www.nytimes.com/2018/05/18/us/school-shooting-santa-fe-texas.html') | ||
assert 'SANTA FE, Tex.' in parser.body | ||
|
||
|
||
@patch('parsers.baseparser.grab_url') | ||
def test_new_format(mock_grab_url): | ||
from test_nyt_data import HTML_NEW_FORMAT | ||
mock_grab_url.return_value = HTML_NEW_FORMAT | ||
parser = NYTParser('https://www.nytimes.com/2018/05/16/us/politics/mueller-trump-indictment.html') | ||
assert 'Trump' in parser.body | ||
assert len(parser.body.split('\n\n')) == 28 | ||
assert not parser.title.endswith('- The New York Times') | ||
|
||
@patch('parsers.baseparser.grab_url') | ||
def test_corrections(mock_grab_url): | ||
from test_nyt_data import HTML_WITH_CORRECTION | ||
mock_grab_url.return_value = HTML_WITH_CORRECTION | ||
parser = NYTParser('https://www.nytimes.com/2018/06/05/world/europe/greece-macedonia.html') | ||
assert 'Correction:' in parser.body |
Oops, something went wrong.