mirror of
https://github.com/jazzband/django-ddp.git
synced 2026-05-19 04:51:11 +00:00
Add AccountsTestCase with login.
This commit is contained in:
parent
f051986595
commit
76cf621ef6
1 changed files with 44 additions and 0 deletions
44
dddp/accounts/tests.py
Normal file
44
dddp/accounts/tests.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
from dddp import tests
|
||||
|
||||
|
||||
class AccountsTestCase(tests.DDPServerTestCase):
|
||||
|
||||
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].get('session', None)},
|
||||
],
|
||||
)
|
||||
|
||||
id_ = sockjs.call(
|
||||
'login', {'user': 'invalid@example.com', 'password': 'foo'},
|
||||
)
|
||||
msgs = sockjs.recv()
|
||||
self.assertEqual(
|
||||
msgs, [
|
||||
{
|
||||
'msg': 'result',
|
||||
'error': {
|
||||
'error': 500,
|
||||
'reason': "(403, 'Authentication failed.')",
|
||||
},
|
||||
'id': id_,
|
||||
},
|
||||
],
|
||||
)
|
||||
|
||||
sockjs.close()
|
||||
Loading…
Reference in a new issue