diff options
author | ardi69 <armin@diedering.de> | 2015-04-18 14:08:18 +0200 |
---|---|---|
committer | ardi69 <armin@diedering.de> | 2015-04-18 14:08:18 +0200 |
commit | 6e8f84e1dc06cff6fa9387559992f555182c1774 (patch) | |
tree | 476600f9896fae029880e4049eb4c5e6021b202d /tests | |
parent | fix: config cast (diff) | |
parent | Spare code cosmetics (5) (diff) | |
download | pyload-6e8f84e1dc06cff6fa9387559992f555182c1774.tar.xz |
Merge pull request #3 from vuolter/0.4.10
merge vuolter HEAD
Diffstat (limited to 'tests')
-rw-r--r-- | tests/APIExerciser.py | 40 | ||||
-rw-r--r-- | tests/clonedigger.sh | 2 | ||||
-rw-r--r-- | tests/code_analysis.sh | 6 | ||||
-rw-r--r-- | tests/test_api.py | 2 | ||||
-rw-r--r-- | tests/test_json.py | 2 |
5 files changed, 25 insertions, 27 deletions
diff --git a/tests/APIExerciser.py b/tests/APIExerciser.py index 38dd9fceb..d17f81ae2 100644 --- a/tests/APIExerciser.py +++ b/tests/APIExerciser.py @@ -3,15 +3,15 @@ import string from threading import Thread -from random import choice, random, sample, randint -from time import time, sleep +from random import choice, sample, randint +from time import time from math import floor import gc - from traceback import print_exc, format_exc from pyload.remote.thriftbackend.ThriftClient import ThriftClient, Destination + def createURLs(): """ create some urls, some may fail """ urls = [] @@ -24,6 +24,7 @@ def createURLs(): return urls + AVOID = (0, 3, 8) idPool = 0 @@ -31,9 +32,10 @@ sumCalled = 0 def startApiExerciser(core, n): - for i in range(n): + for _i in range(n): APIExerciser(core).start() + class APIExerciser(Thread): def __init__(self, core, thrift=False, user=None, pw=None): @@ -45,17 +47,13 @@ class APIExerciser(Thread): self.count = 0 #: number of methods self.time = time() - if thrift: - self.api = ThriftClient(user=user, password=pw) - else: - self.api = core.api - + self.api = ThriftClient(user=user, password=pw) if thrift else core.api self.id = idPool idPool += 1 - #self.start() + # self.start() def run(self): @@ -63,7 +61,7 @@ class APIExerciser(Thread): self.core.log.info("API Excerciser started %d" % self.id) out = open("error.log", "ab") - #core errors are not logged of course + # core errors are not logged of course out.write("\n" + "Starting\n") out.flush() @@ -87,9 +85,7 @@ class APIExerciser(Thread): self.core.log.info("Approx. %.2f calls per second." % persec) self.core.log.info("Approx. %.2f ms per call." % (1000 / persec)) self.core.log.info("Collected garbage: %d" % gc.collect()) - - - #sleep(random() / 500) + # sleep(random() / 500) def testAPI(self): @@ -97,10 +93,10 @@ class APIExerciser(Thread): m = ["statusDownloads", "statusServer", "addPackage", "getPackageData", "getFileData", "deleteFiles", "deletePackages", "getQueue", "getCollector", "getQueueData", "getCollectorData", "isCaptchaWaiting", - "getCaptchaTask", "stopAllDownloads", "getAllInfo", "getServices" , "getAccounts", "getAllUserData"] + "getCaptchaTask", "stopAllDownloads", "getAllInfo", "getServices", "getAccounts", "getAllUserData"] method = choice(m) - #print "Testing:", method + # print "Testing:", method if hasattr(self, method): res = getattr(self, method)() @@ -110,7 +106,7 @@ class APIExerciser(Thread): self.count += 1 sumCalled += 1 - #print res + # print res def addPackage(self): @@ -122,7 +118,8 @@ class APIExerciser(Thread): def deleteFiles(self): info = self.api.getQueueData() - if not info: return + if not info: + return pack = choice(info) fids = pack.links @@ -134,11 +131,12 @@ class APIExerciser(Thread): def deletePackages(self): info = choice([self.api.getQueue(), self.api.getCollector()]) - if not info: return + if not info: + return pids = [p.pid for p in info] - if len(pids): - pids = sample(pids, randint(1, max(floor(len(pids) / 2.5), 1))) + if pids: + pids = sample(pids, randint(1, max(floor(len(pids) / 2.5), 1))) self.api.deletePackages(pids) diff --git a/tests/clonedigger.sh b/tests/clonedigger.sh index 641e7ff64..4c53eab0d 100644 --- a/tests/clonedigger.sh +++ b/tests/clonedigger.sh @@ -1,4 +1,4 @@ #!/bin/sh PYLOAD="../pyload" # Check pyload directory -clonedigger -o cpd.xml --cpd-output --fast --ignore-dir="remote" $PYLOAD +clonedigger -o cpd.xml --cpd-output --fast --ignore-dir="remote" ${PYLOAD} diff --git a/tests/code_analysis.sh b/tests/code_analysis.sh index c4dc8e99a..cba614929 100644 --- a/tests/code_analysis.sh +++ b/tests/code_analysis.sh @@ -4,12 +4,12 @@ PYLOAD="../pyload" # Check pyload directory echo "Running sloccount ..." REPORT="sloccount.sc" -sloccount --duplicates --wide --details $PYLOAD > $REPORT && echo "Done. Report saved to $REPORT" +sloccount --duplicates --wide --details ${PYLOAD} > ${REPORT} && echo "Done. Report saved to $REPORT" echo "Running pep8 ..." REPORT="pep8.txt" -pep8 $PYLOAD > $REPORT && echo "Done. Report saved to $REPORT" +pep8 ${PYLOAD} > ${REPORT} && echo "Done. Report saved to $REPORT" echo "Running pylint ..." REPORT="pylint.txt" -pylint --reports=no $PYLOAD > $REPORT && echo "Done. Report saved to $REPORT" +pylint --reports=no ${PYLOAD} > ${REPORT} && echo "Done. Report saved to $REPORT" diff --git a/tests/test_api.py b/tests/test_api.py index 9c12da51c..13e783d54 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -20,5 +20,5 @@ class TestApi(object): @nottest def test_random(self): - for _ in range(0, 100): + for _i in range(0, 100): self.api.testAPI() diff --git a/tests/test_json.py b/tests/test_json.py index f87a32139..a83ef0a24 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -14,7 +14,7 @@ class TestJson(object): def call(self, name, post=None): if not post: post = {} - post["session"] = self.key + post['session'] = self.key u = urlopen(url % name, data=urlencode(post)) return loads(u.read()) |