forked from leancloud/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_op.py
More file actions
48 lines (36 loc) · 1.33 KB
/
Copy pathtest_op.py
File metadata and controls
48 lines (36 loc) · 1.33 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
# coding: utf-8
import leancloud
from leancloud import Object
from leancloud import operation
__author__ = 'asaka <lan@leancloud.rocks>'
def test_set():
s = operation.Set(10)
assert s.value == 10
def test_unset():
s = operation.Unset()
assert s._apply(operation.Set(10)) == operation._UNSET
def test_increment():
s = operation.Increment(1)
assert s.amount == 1
previous = operation.Increment(2)
new = s._merge(previous)
assert isinstance(new, operation.Increment)
assert new.amount == 3
def test_apply_relation_op():
album = leancloud.Object.create("Album",
objectId="abc001",
title="variety")
band1 = leancloud.Object.create("Band",
objectId="abc101",
name="xxx")
band2 = leancloud.Object.create("Band",
objectId="abc102",
name="ooo")
relation = album.relation("band")
op = operation.Relation([band1], [band2])
val = op._apply(None, album, "band")
assert isinstance(val, leancloud.Relation)
val._ensure_parent_and_key(album, "band")
val = op._apply(relation)
assert isinstance(val, leancloud.Relation)
val._ensure_parent_and_key(album, "band")