summaryrefslogtreecommitdiffstats
path: root/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'tests/api')
-rw-r--r--tests/api/test_JSONBackend.py6
-rw-r--r--tests/api/test_WebSocketAPI.py33
2 files changed, 37 insertions, 2 deletions
diff --git a/tests/api/test_JSONBackend.py b/tests/api/test_JSONBackend.py
index a3805497b..8d3373f65 100644
--- a/tests/api/test_JSONBackend.py
+++ b/tests/api/test_JSONBackend.py
@@ -2,6 +2,7 @@
from nose.tools import raises
+from module.remote.ttypes import Forbidden
from module.remote.JSONClient import JSONClient
class TestJSONBackend:
@@ -18,10 +19,11 @@ class TestJSONBackend:
ret = self.client.login("WrongUser", "wrongpw")
assert ret == False
- @raises(Exception)
+ @raises(Forbidden)
def test_access(self):
self.client.getServerVersion()
- @raises(Exception)
+ @raises(AttributeError)
def test_unknown_method(self):
+ self.client.login("User", "test")
self.client.sdfdsg()
diff --git a/tests/api/test_WebSocketAPI.py b/tests/api/test_WebSocketAPI.py
new file mode 100644
index 000000000..ac22d044e
--- /dev/null
+++ b/tests/api/test_WebSocketAPI.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+
+from nose.tools import raises
+
+from module.remote.ttypes import Forbidden
+from module.remote.WSClient import WSClient
+
+class TestWebSocketAPI:
+
+ def setUp(self):
+ self.client = WSClient()
+ self.client.connect()
+
+ def tearDown(self):
+ self.client.close()
+
+ def test_login(self):
+ self.client.login("User", "test")
+ self.client.getServerVersion()
+ self.client.logout()
+
+ def test_wronglogin(self):
+ ret = self.client.login("WrongUser", "wrongpw")
+ assert ret == False
+
+ @raises(Forbidden)
+ def test_access(self):
+ self.client.getServerVersion()
+
+ @raises(AttributeError)
+ def test_unknown_method(self):
+ self.client.login("User", "test")
+ self.client.sdfdsg()