Add searching to nim client

This commit is contained in:
Christine Dodrill 2015-08-12 12:45:05 -07:00
parent e4a824064c
commit 87d10f89a5
1 changed files with 15 additions and 0 deletions

View File

@ -1,3 +1,4 @@
import cgi
import httpclient import httpclient
import json import json
@ -48,6 +49,9 @@ proc all_episodes*(): seq[Episode] =
proc get_season*(season: int): seq[Episode] = proc get_season*(season: int): seq[Episode] =
getJson("/season/" & $season)["episodes"].newEpisodeListFromNode getJson("/season/" & $season)["episodes"].newEpisodeListFromNode
proc search*(term: string): seq[Episode] =
getJson("/search?q=" & term.encodeURL())["episodes"].newEpisodeListFromNode
when isMainModule: when isMainModule:
import unittest import unittest
@ -92,3 +96,14 @@ when isMainModule:
except: except:
echo getCurrentExceptionMsg() echo getCurrentExceptionMsg()
fail fail
test "search for pony":
try:
var eps = search("pony")
assert eps.len > 0
except:
echo getCurrentExceptionMsg()
fail