forked from hagsteel/swampdragon
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_base_router_send.py
27 lines (20 loc) · 989 Bytes
/
test_base_router_send.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from swampdragon.route_handler import BaseRouter, ERROR, SUCCESS, LOGIN_REQUIRED
from swampdragon.testing.dragon_testcase import DragonTestCase
class FooRouter(BaseRouter):
route_name = 'foo'
class TestBaseRouter(DragonTestCase):
def setUp(self):
self.router = FooRouter(self.connection)
def test_send(self):
message = 'today is a good day'
self.router.send(message)
self.assertEqual(self.connection.last_message['data'], message)
self.assertEqual(self.connection.last_message['context']['state'], SUCCESS)
def test_send_error(self):
error = "it's gone wrong"
self.router.send_error(error)
self.assertEqual(self.connection.last_message['data'], error)
self.assertEqual(self.connection.last_message['context']['state'], ERROR)
def test_login_required(self):
self.router.send_login_required()
self.assertEqual(self.connection.last_message['context']['state'], LOGIN_REQUIRED)