forked from RedisLabsModules/RLTest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_example.py
75 lines (57 loc) · 1.82 KB
/
test_example.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
67
68
69
70
71
72
73
74
75
from RLTest import Env
import time
class testExample():
'''
run all tests on a single env without taking
env down between tests
'''
def __init__(self):
self.env = Env()
def setUp(self):
self.env.debugPrint('setUp', True)
self.env.cmd('set', 'foo', 'bar')
def tearDown(self):
self.env.debugPrint('tearDown', True)
self.env.expect('get', 'foo').equal('bar')
self.env.cmd('flushall')
def testExample(self):
con = self.env.getConnection()
con.set('x', 1)
self.env.assertEqual(con.get('x'), '1')
def testExample1(self):
con = self.env.getConnection()
con.set('x', 1)
self.env.assertEqual(con.get('x'), '1')
self.env.assertFalse(True) # check failure
def testExample2(self):
con = self.env.getConnection()
con.set('x', 1)
self.env.assertEqual(con.get('x'), '1')
# run each test on different env
def test_example():
env = Env(testDescription="this is an example")
con = env.getConnection()
con.set('x', 1)
env.assertEqual(con.get('x'), '1')
env.assertTrue(False)
env.assertTrue(False)
def test_example_2():
env = Env()
env.assertOk(env.cmd('set', 'x', '1'))
env.expect('get', 'x').equal('1')
env.expect('lpush', 'list', '1', '2', '3').equal(3)
env.expect('lrange', 'list', '0', '-1').debugPrint().contains('1')
env.debugPrint('this is some debug printing')
def test_example_3():
env = Env(useSlaves=True, env='oss')
con = env.getConnection()
con.set('x', 1)
con2 = env.getSlaveConnection()
time.sleep(0.1)
env.assertEqual(con2.get('x'), '1')
def test_skip():
env = Env(useSlaves=True, env='oss')
env.skip()
def test_exception():
env = Env(useSlaves=True, env='oss')
raise Exception()