def test_multiple(self): q = Query(QueryTests.template) q.searchTerms = 'zx81' q.startIndex = 15 q.count = 15 self.assertEqual(q.url(), 'http://www.koders.com/?i=15&s=zx81&c=15&output=rss')
def test_multiple(self): q = Query(QueryTests.template) q.searchTerms = 'zx81' q.startIndex = 15 q.count = 15 self.assertEqual(q.url(), 'http://www.koders.com/?s=zx81&output=rss&c=15&i=15')
def test_result(self): query = Query("http://www.koders.com/?s={searchTerms}&p={startPage}&output=rss&c={count}&i={startIndex}") query.searchTerms = "python" results = Results(query) self.assertEqual(True, (results.totalResults > 0)) self.assertEqual(results.startIndex, 1) self.assertEqual(results.itemsPerPage, 25) self.assertEqual(True, len(results.items) > 0)
def test_extra_param(self): template = "http://www.koders.com/?s={searchTerms}&p={startPage}&output=rss&c={count}&i={startIndex}&key={key}" q = Query(template) self.assertTrue(q.has_macro('key')) q.searchTerms = 'zx81' q.key = 'abc123' self.assertEqual( q.url(), 'http://www.koders.com/?s=zx81&output=rss&key=abc123')
def test_result(self): query = Query( "http://www.koders.com/?s={searchTerms}&p={startPage}&output=rss&c={count}&i={startIndex}" ) query.searchTerms = "python" results = Results(query) self.assertEqual(True, (results.totalResults > 0)) self.assertEqual(results.startIndex, 1) self.assertEqual(results.itemsPerPage, 25) self.assertEqual(True, len(results.items) > 0)
def test_iterator_with_page(self): query = Query("http://www.koders.com/?s={searchTerms}&p={startPage}&output=rss") query.searchTerms = "python" results = Results(query) count = 0 for i in results: count += 1 if count > 75: break self.assertEqual(True, count > 75)
def test_prefix(self): template = "http://worldcat.org/webservices/catalog/search/worldcat/opensearch?q={searchTerms}&start={startIndex?}&count={resultSize?}&format=atom&wskey={wcapi:wskey}&cformat={wcapi:cformat?}" q = Query(template) self.assertTrue(q.has_macro('searchTerms')) self.assertTrue(q.has_macro('wcapi__wskey')) q.searchTerms = "computer" q.wcapi__wskey = "abc123" self.assertEqual( q.url(), 'http://worldcat.org/webservices/catalog/search/worldcat/opensearch?q=computer&format=atom&wskey=abc123' )
def test_iterator_with_page(self): query = Query( "http://www.koders.com/?s={searchTerms}&p={startPage}&output=rss" ) query.searchTerms = "python" results = Results(query) count = 0 for i in results: count += 1 if count > 75: break self.assertEqual(True, count > 75)
def test_searchTerms(self): q = Query(QueryTests.template) q.searchTerms = 'zx81' self.assertEqual(q.url(), 'http://www.koders.com/?s=zx81&output=rss')