Пример #1
0
 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')
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
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)
Пример #5
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)
Пример #6
0
 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')
Пример #7
0
 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'
     )
Пример #8
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')
Пример #9
0
 def do_opensearch_Query(self):
   from opensearch import Query
   return Query()
Пример #10
0
 def test_searchTerms(self):
     q = Query(QueryTests.template)
     q.searchTerms = 'zx81'
     self.assertEqual(q.url(), 'http://www.koders.com/?s=zx81&output=rss')
Пример #11
0
 def test_startIndex(self):
     q = Query(QueryTests.template)
     q.startIndex = 5
     self.assertEqual(q.url(), 'http://www.koders.com/?i=5&output=rss')
Пример #12
0
 def test_count(self):
     q = Query(QueryTests.template)
     q.count = 25
     self.assertEqual(q.url(), 'http://www.koders.com/?c=25&output=rss')
Пример #13
0
 def test_searchTerms(self):
     q = Query(QueryTests.template)
     q.searchTerms = 'zx81'
     self.assertEqual(q.url(), 'http://www.koders.com/?s=zx81&output=rss')
Пример #14
0
 def test_startIndex(self):
     q = Query(QueryTests.template)
     q.startIndex = 5
     self.assertEqual(q.url(), 'http://www.koders.com/?output=rss&i=5')
Пример #15
0
 def test_startPage(self):
     q = Query(QueryTests.template)
     q.startPage = 5
     self.assertEqual(q.url(), 'http://www.koders.com/?p=5&output=rss')
Пример #16
0
 def test_count(self):
     q = Query(QueryTests.template)
     q.count = 25
     self.assertEqual(q.url(), 'http://www.koders.com/?output=rss&c=25')