Skip to content

Commit

Permalink
TEST: check that all returned items are same length
Browse files Browse the repository at this point in the history
  • Loading branch information
MeNsaaH committed Oct 2, 2019
1 parent 24a4fb4 commit 6e40ea2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 4 additions & 3 deletions search_engine_parser/core/engines/googlescholar.py
Expand Up @@ -2,8 +2,8 @@
Parser for google scholar search results
"""

from search_engine_parser.core.base import BaseSearch
import re
from search_engine_parser.core.base import BaseSearch


class GoogleScholarSearch(BaseSearch):
Expand All @@ -12,8 +12,9 @@ class GoogleScholarSearch(BaseSearch):
"""
name = "GoogleScholar"
search_url = "https://scholar.google.gr/scholar?start={page}&q={query}&hl=en"
summary = "\tGoogle Scholar is a freely accessible web search engine that indexes the full text" \
" or metadata of scholarly literature across an array of publishing formats and disciplines."
summary = "\tGoogle Scholar is a freely accessible web search engine that indexes the full "\
"text or metadata of scholarly literature across an array of publishing formats and "\
"disciplines."

def parse_soup(self, soup):
"""
Expand Down
11 changes: 11 additions & 0 deletions search_engine_parser/tests/base.py
Expand Up @@ -48,3 +48,14 @@ def test_returned_results(self):
def test_links(self):
for link in self.results['links']:
self.assertTrue(validate_url(link))

def test_results_length_are_the_same(self):
""" Tests if returned result items are equal.
:param args: a list/tuple of other keys returned
This should be overwritten for Engine that return more items
"""
items = self.results.keys()
items_set = set(map(lambda x: len(self.results[x]), items))

self.assertTrue(len(items_set) == 1)
1 change: 0 additions & 1 deletion search_engine_parser/tests/test_search.py
Expand Up @@ -97,7 +97,6 @@ def test_returned_results(self):
self.assertTrue(len(self.results['links']) >= 10)
self.assertTrue(len(self.results['descriptions']) >= 10)


class MyAnimeListSearchTest(EngineTestBase, EngineTests):
engine_class = MyAnimeListSearch

Expand Down

0 comments on commit 6e40ea2

Please sign in to comment.