-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_redis_actor.py
67 lines (45 loc) · 1.49 KB
/
test_redis_actor.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
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
55
56
57
58
59
60
61
62
63
64
65
66
from nose import tools
import unittest, time
from ec2 import WarningErr
from ec2.redis import API
from ec2.utils.decorator import *
from ec2.conf.enabled import redis_conf
#from ec2.utils.logger import NoseLogging as logger
#logger.start()
@filters( has_keys('pid', 'key') )
def foo(ctrl,message):
return True
@filters( has_keys('pid',), pid2rcd('aaa') )
def foo2(ctrl,message):
return message
class DecoratorTest(unittest.TestCase):
def setUp(self):
self.db = API.db('default')
def tearDown(self):
self._clear_keys()
def _clear_keys(self):
for k in self.db._redis.keys('test:*'):
self.db._redis.delete(k)
@tools.raises(WarningErr)
def testMsgNeed_1(self):
foo(None,{})
@tools.raises(WarningErr)
def testMsgNeed_2(self):
foo(None, {'_pid':None,})
@tools.raises(WarningErr)
def testMsgNeed_3(self):
foo(None, {'pid':None,})
@tools.raises(WarningErr)
def testMsgNeed_4(self):
tools.eq_(True, foo(None, {'pid':None,'key':None,}))
def testMsgNeed_5(self):
tools.eq_(True, foo(None, {'pid':1,'key':'a',}))
@tools.raises(WarningErr)
def testPid2Rcd_1(self):
foo2(self, {})
@tools.raises(WarningErr)
def testPid2Rcd_2(self):
foo2(self, {'pid':1,})
def testPid2Rcd_3(self):
pid = self.db.insert_into('aaa',{'hello':'world'})
tools.eq_('world', foo2(self, {'pid':pid,})['hello'])