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_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')