diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/APIExerciser.py | 8 | ||||
-rw-r--r-- | tests/test_api.py | 4 | ||||
-rw-r--r-- | tests/test_json.py | 6 |
3 files changed, 17 insertions, 1 deletions
diff --git a/tests/APIExerciser.py b/tests/APIExerciser.py index 0498d50b8..5e84bfefe 100644 --- a/tests/APIExerciser.py +++ b/tests/APIExerciser.py @@ -36,7 +36,6 @@ def startApiExerciser(core, n): class APIExerciser(Thread): - def __init__(self, core, thrift=False, user=None, pw=None): global idPool @@ -58,6 +57,7 @@ class APIExerciser(Thread): #self.start() + def run(self): self.core.log.info("API Excerciser started %d" % self.id) @@ -91,6 +91,7 @@ class APIExerciser(Thread): #sleep(random() / 500) + def testAPI(self): global sumCalled @@ -111,6 +112,7 @@ class APIExerciser(Thread): #print res + def addPackage(self): name = "".join(sample(string.ascii_letters, 10)) urls = createURLs() @@ -139,6 +141,7 @@ class APIExerciser(Thread): pids = sample(pids, randint(1, max(floor(len(pids) / 2.5), 1))) self.api.deletePackages(pids) + def getFileData(self): info = self.api.getQueueData() if info: @@ -146,13 +149,16 @@ class APIExerciser(Thread): if p.links: self.api.getFileData(choice(p.links).fid) + def getPackageData(self): info = self.api.getQueue() if info: self.api.getPackageData(choice(info).pid) + def getAccounts(self): self.api.getAccounts(False) + def getCaptchaTask(self): self.api.getCaptchaTask(False) diff --git a/tests/test_api.py b/tests/test_api.py index 08c775aaf..6ef3e6ccd 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -7,14 +7,18 @@ from nose.tools import nottest class TestApi(object): + def __init__(self): self.api = APIExerciser.APIExerciser(None, True, "TestUser", "pwhere") + def test_login(self): assert self.api.api.login("crapp", "wrong pw") is False # takes really long, only test when needed @nottest + + def test_random(self): for _ in range(0, 100): self.api.testAPI() diff --git a/tests/test_json.py b/tests/test_json.py index da399325c..f87a32139 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -11,21 +11,25 @@ url = "http://localhost:8001/api/%s" class TestJson(object): + def call(self, name, post=None): if not post: post = {} post["session"] = self.key u = urlopen(url % name, data=urlencode(post)) return loads(u.read()) + def setUp(self): u = urlopen(url % "login", data=urlencode({"username": "TestUser", "password": "pwhere"})) self.key = loads(u.read()) assert self.key is not False + def test_wronglogin(self): u = urlopen(url % "login", data=urlencode({"username": "crap", "password": "wrongpw"})) assert loads(u.read()) is False + def test_access(self): try: urlopen(url % "getServerVersion") @@ -34,12 +38,14 @@ class TestJson(object): else: assert False + def test_status(self): ret = self.call("statusServer") log(1, str(ret)) assert "pause" in ret assert "queue" in ret + def test_unknown_method(self): try: self.call("notExisting") |