forked from miguelgrinberg/python-socketio
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_asyncio_redis_manager.py
More file actions
54 lines (42 loc) · 1.9 KB
/
test_asyncio_redis_manager.py
File metadata and controls
54 lines (42 loc) · 1.9 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import sys
import unittest
if sys.version_info >= (3, 5):
from socketio import asyncio_redis_manager
@unittest.skipIf(sys.version_info < (3, 5), 'only for Python 3.5+')
class TestAsyncRedisManager(unittest.TestCase):
def test_default_url(self):
self.assertEqual(asyncio_redis_manager._parse_redis_url('redis://'),
('localhost', 6379, None, 0))
def test_only_host_url(self):
self.assertEqual(
asyncio_redis_manager._parse_redis_url('redis://redis.host'),
('redis.host', 6379, None, 0))
def test_no_db_url(self):
self.assertEqual(
asyncio_redis_manager._parse_redis_url('redis://redis.host:123/1'),
('redis.host', 123, None, 1))
def test_no_port_url(self):
self.assertEqual(
asyncio_redis_manager._parse_redis_url('redis://redis.host/1'),
('redis.host', 6379, None, 1))
def test_password(self):
self.assertEqual(
('redis.host', 6379, 'pw', 1))
def test_no_host_url(self):
self.assertEqual(
asyncio_redis_manager._parse_redis_url('redis://:123/1'),
('localhost', 123, None, 1))
def test_no_host_password_url(self):
self.assertEqual(
asyncio_redis_manager._parse_redis_url('redis://:pw@:123/1'),
('localhost', 123, 'pw', 1))
def test_bad_port_url(self):
self.assertRaises(ValueError, asyncio_redis_manager._parse_redis_url,
'redis://localhost:abc/1')
def test_bad_db_url(self):
self.assertRaises(ValueError, asyncio_redis_manager._parse_redis_url,
'redis://localhost:abc/z')
def test_bad_scheme_url(self):
self.assertRaises(ValueError, asyncio_redis_manager._parse_redis_url,
'http://redis.host:123/1')