-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
107 additions
and
97 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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
__pycache__/ | ||
GoogleNews.egg-info/ | ||
.DS_Store | ||
/venv | ||
.idea | ||
*.html | ||
._* | ||
.coverage |
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,14 @@ | ||
language: python | ||
python: | ||
- "3.6" | ||
# command to install dependencies | ||
install: | ||
- pip install beautifulsoup4 | ||
- pip install coverage | ||
- pip install coveralls | ||
# command to run tests | ||
script: | ||
- coverage run -m unittest discover 'test' 'test*.py' | ||
# coverage | ||
after_success: | ||
coveralls |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
setuptools.setup( | ||
name="GoogleNews", | ||
version="1.3.8", | ||
version="1.3.9", | ||
author="Hurin Hu", | ||
author_email="[email protected]", | ||
description="Google News search for Python", | ||
|
@@ -15,7 +15,7 @@ | |
packages=setuptools.find_packages(), | ||
install_requires=['beautifulsoup4'], | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.6", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
], | ||
|
Empty file.
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,70 @@ | ||
import unittest | ||
|
||
from GoogleNews import GoogleNews | ||
|
||
keyword = 'Apple' | ||
|
||
class NumbersTest(unittest.TestCase): | ||
|
||
def testResultNumberWithDefaultPage(self): | ||
googlenews = GoogleNews() | ||
googlenews.search(keyword) | ||
length = len(googlenews.result()) | ||
self.assertEqual(length, 10) | ||
print('Result length with only one page is correct') | ||
|
||
def testResultNumberWithTwoPages(self): | ||
googlenews = GoogleNews() | ||
googlenews.search(keyword) | ||
googlenews.getpage(2) | ||
length = len(googlenews.result()) | ||
self.assertEqual(length, 20) | ||
print('Result length with two pages is correct') | ||
|
||
class TestStringMethods(unittest.TestCase): | ||
|
||
def testResultContainsKeyword(self): | ||
googlenews = GoogleNews() | ||
googlenews.search(keyword) | ||
result = googlenews.result()[0] | ||
self.assertIn(keyword.lower(), result.get('desc').lower()) | ||
print('Result contains keyword') | ||
|
||
def testResultHasLink(self): | ||
googlenews = GoogleNews() | ||
googlenews.search(keyword) | ||
result = googlenews.result()[0] | ||
self.assertIn('http', result.get('link').lower()) | ||
print('Result contains http link') | ||
|
||
def testResultHasImage(self): | ||
googlenews = GoogleNews() | ||
googlenews.search(keyword) | ||
result = googlenews.result()[0] | ||
self.assertIn('base64', result.get('img').lower()) | ||
print('Result contains image') | ||
|
||
def testResultHasTitle(self): | ||
googlenews = GoogleNews() | ||
googlenews.search(keyword) | ||
result = googlenews.result()[0] | ||
self.assertIsNot('', result.get('title').lower()) | ||
print('Result title is not empty') | ||
|
||
def testResultHasMedia(self): | ||
googlenews = GoogleNews() | ||
googlenews.search(keyword) | ||
result = googlenews.result()[0] | ||
self.assertIsNot('', result.get('media').lower()) | ||
print('Result media is not empty') | ||
|
||
def testResultHasDate(self): | ||
googlenews = GoogleNews() | ||
googlenews.search(keyword) | ||
result = googlenews.result()[0] | ||
self.assertIsNot('', result.get('date').lower()) | ||
print('Result date is not empty') | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |