summaryrefslogtreecommitdiffstats
path: root/tests/api/ApiTester.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/api/ApiTester.py')
-rw-r--r--tests/api/ApiTester.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/api/ApiTester.py b/tests/api/ApiTester.py
new file mode 100644
index 000000000..e9a185947
--- /dev/null
+++ b/tests/api/ApiTester.py
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+
+from pyload.remote.JSONClient import JSONClient
+from pyload.remote.WSClient import WSClient
+
+from tests.helper.config import webAddress, wsAddress
+
+from ApiProxy import ApiProxy
+
+class ApiTester:
+
+ tester= []
+
+ @classmethod
+ def register(cls, tester):
+ cls.tester.append(tester)
+
+ @classmethod
+ def get_methods(cls):
+ """ All available methods for testing """
+ methods = []
+ for t in cls.tester:
+ methods.extend(getattr(t, attr) for attr in dir(t) if attr.startswith("test_"))
+ return methods
+
+ def __init__(self):
+ ApiTester.register(self)
+ self.api = None
+
+ def setApi(self, api):
+ self.api = api
+
+ def enableJSON(self):
+ self.api = ApiProxy(JSONClient(webAddress))
+
+ def enableWS(self):
+ self.api = ApiProxy(WSClient(wsAddress))