No older revisions available
No older revisions available
# ---- AT_BookSearch.py ----
import unittest
import httplib, urllib
DEFAULT_HEADER = {"Content-Type":"application/x-www-form-urlencoded",
"Referer":"http://165.194.100.2/cgi-bin/mcu100?LIBRCODE=ATSL&USERID=*&SYSDB=R",
"Accept":"image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*"}
DEFAULT_SERVICE_IP = "165.194.17.56"
DEFAULT_SERVICE_PORT = 8080
DEFAULT_SERVICE_SIMPLE_PATH = "/servlet/SimpleSearch"
DEFAULT_SERVICE_ADVANCED_PATH = "/servlet/AdvancedSearch"
def getSimpleSearchResponse(params):
params=urllib.urlencode(params)
conn = httplib.HTTPConnection(DEFAULT_SERVICE_IP, DEFAULT_SERVICE_PORT)
conn.request("POST", DEFAULT_SERVICE_SIMPLE_PATH, params, DEFAULT_HEADER)
response = conn.getresponse()
print response.status, response.reason
data = response.read()
conn.close()
return data
def getAdvancedSearchResponse(params):
params=urllib.urlencode(params)
conn = httplib.HTTPConnection(DEFAULT_SERVICE_IP, DEFAULT_SERVICE_PORT)
conn.request("POST", DEFAULT_SERVICE_ADVANCED_PATH, params, DEFAULT_HEADER)
response = conn.getresponse()
print response.status, response.reason
data = response.read()
conn.close()
return data
class TestAdvancedSearch(unittest.TestCase):
def testOne(self):
params = {'TI':'Test', 'AU':'', 'IB':'', 'PU':'', 'OP1':'','OP2':'','OP3':''}
data = getAdvancedSearchResponse(params)
self.assert_(data.count("<TR>") > 70)
def testKorean(self):
params = {'TI':'', 'AU':'ê¹~@ì~F~Lì~[~T', 'IB':'', 'PU':'', 'OP1':'','OP2':'','OP3':''}
data = getAdvancedSearchResponse(params)
self.assert_(data.count("<TR>") > 10)
def testKoreanTwo(self):
params = {'TI':'í~U~\ê¸~@', 'AU':'', 'IB':'', 'PU':'', 'OP1':'','OP2':'','OP3':''}
data = getAdvancedSearchResponse(params)
self.assert_(data.count("<TR>") > 10)
class TestSimpleSearch(unittest.TestCase):
def testOne(self):
params = {'keyword':'í~U~\ê¸~@'}
data = getSimpleSearchResponse(params)
self.assert_(data.count("<TR>") > 10)
def testIsbn(self):
params = {'keyword':'897087223X'}
data = getSimpleSearchResponse(params)
self.assert_(data.count("ê¹~@ë¶~Hê¾¼") > 0)
def testKoreanAndNumber(self):
params = {'keyword':'í~U~\ê¸~@3'}
data = getSimpleSearchResponse(params)
self.assert_(data.count("<TR>") > 10)
def testKoreanAndNumberWithSpace(self):
params = {'keyword':'í~U~\ê¸~@ 3'}
data = getSimpleSearchResponse(params)
self.assert_(data.count("<TR>") > 10)
if __name__=="__main__":
unittest.main(argv=('','-v'))