django-ddp/dddp/accounts/tests.py

49 lines
1.2 KiB
Python
Raw Permalink Normal View History

"""Django DDP Accounts test suite."""
from __future__ import unicode_literals
import sys
2015-12-21 10:08:36 +00:00
from dddp import tests
class AccountsTestCase(tests.DDPServerTestCase):
# gevent-websocket doesn't work with Python 3 yet
@tests.expected_failure_if(sys.version_info.major == 3)
2015-12-21 10:08:36 +00:00
def test_login_no_accounts(self):
sockjs = self.server.sockjs('/sockjs/1/a/websocket')
resp = sockjs.websocket.recv()
self.assertEqual(resp, 'o')
msgs = sockjs.recv()
self.assertEqual(
msgs, [
{'server_id': '0'},
],
)
sockjs.connect('1', 'pre2', 'pre1')
msgs = sockjs.recv()
self.assertEqual(
msgs, [
{'msg': 'connected', 'session': msgs[0]['session']},
2015-12-21 10:08:36 +00:00
],
)
id_ = sockjs.call(
'login', {'user': 'invalid@example.com', 'password': 'foo'},
)
msgs = sockjs.recv()
self.assertEqual(
msgs, [
{
'msg': 'result', 'id': id_,
2015-12-21 10:08:36 +00:00
'error': {
'error': 403, 'reason': 'Authentication failed.',
2015-12-21 10:08:36 +00:00
},
},
],
)
sockjs.close()