(use posix mw testeez sxpath) (default-wiki "http://en.wikipedia.org/w/api.php") (testeez "mw" (test/equal "Raw XML response from Wikipedia" (let* ((response (raw-api-call '((action . query)(meta . siteinfo)(format . xml)))) (len (string-length response))) (string-append (substring response 0 33) (substring response (- len 14)))) "") (test/equal "Raw json response from Wikipedia" (let* ((response (raw-api-call '((action . query)(meta . siteinfo)(format . json)))) (len (string-length response))) (substring response 0 32)) "{\"query\":{\"general\":{\"mainpage\":") (test/equal "pipejoin" (pipejoin '(a "b" "c d" 12)) "a|b|c d|12") (test/equal "sx-call sanity check" (let* ((response (sx-call '((action . query)(meta . siteinfo))))) (map (sxpath "api/query/general/@wikiid") response)) '(((wikiid "enwiki")))) (test/equal "check a user's edit count" (let* ((response (user-details "TonyBot")) (s ((sxpath "api/query/allusers/u/@editcount") response))) (signum (- (string->number (cadar s)) 2134))) +1) (test/equal "prop-revisions" (let* ((response (sx-call (prop-revisions "Scheme (programming language)" startid: 321830591 endid: 321830591 section: 6 prop: 'content))) (content ((sxpath "//text()") response)) (text (and (pair? content) (car content)))) (substring text 99 114)) "lambda calculus") (test/equal "prop-categories" (let* ((response (sx-call (prop-categories "Abraham Lincoln" categories: "Category: Presidents of the United States"))) (content ((sxpath "//categories/cl/@title") response))) (and (pair? content) (cadar content))) "Category:Presidents of the United States") (test/equal "Fetch just two revisions" (let* ((response (sx-call-once (prop-revisions "Main Page" limit: 2))) (revids ((sxpath "api/query/pages/page/revisions/rev/@revid") response)) (count (length revids))) count) 2) )