|
@@ -12,6 +12,21 @@ class TestShare(BaseTest):
|
12
|
12
|
shared = SharedDataManager()
|
13
|
13
|
|
14
|
14
|
class Foo(object):
|
|
15
|
+ counter = shared.create('counter', value=0)
|
|
16
|
+
|
|
17
|
+ foo = Foo()
|
|
18
|
+ foo.counter = 42
|
|
19
|
+
|
|
20
|
+ assert shared.get('counter') == 42
|
|
21
|
+
|
|
22
|
+ foo.counter = 48
|
|
23
|
+
|
|
24
|
+ assert shared.get('counter') == 48
|
|
25
|
+
|
|
26
|
+ def test_default_value(self):
|
|
27
|
+ shared = SharedDataManager()
|
|
28
|
+
|
|
29
|
+ class Foo(object):
|
15
|
30
|
counter = shared.create('counter', 0)
|
16
|
31
|
|
17
|
32
|
foo = Foo()
|
|
@@ -28,8 +43,8 @@ class TestShare(BaseTest):
|
28
|
43
|
|
29
|
44
|
class Foo(object):
|
30
|
45
|
counter = shared.create(
|
31
|
|
- '{id}_counter',
|
32
|
|
- 0,
|
|
46
|
+ ['{id}', 'counter'],
|
|
47
|
+ value=0,
|
33
|
48
|
indexes=[],
|
34
|
49
|
)
|
35
|
50
|
|
|
@@ -40,11 +55,11 @@ class TestShare(BaseTest):
|
40
|
55
|
foo = Foo()
|
41
|
56
|
foo.counter = 42
|
42
|
57
|
|
43
|
|
- assert shared.get('{}_counter'.format(foo.id)) == 42
|
|
58
|
+ assert shared.get(foo.id, 'counter') == 42
|
44
|
59
|
|
45
|
60
|
foo.counter = 48
|
46
|
61
|
|
47
|
|
- assert shared.get('{}_counter'.format(foo.id)) == 48
|
|
62
|
+ assert shared.get(foo.id, 'counter') == 48
|
48
|
63
|
|
49
|
64
|
def test_multiple_uses(self):
|
50
|
65
|
shared = SharedDataManager()
|