Skip to content

Commit 81aba2c

Browse files
committed
test(LeanObject): add tests for is_existed()
1 parent 439b24d commit 81aba2c

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

tests/test_object.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ def test_fetch(): # type: () -> None
237237
album.save()
238238

239239
album_1 = Album.create_without_data(album.id)
240+
assert album_1.is_existed() is False
240241
album_1.fetch(include=['parent'], select=['name', 'parent'])
242+
assert album_1.is_existed() is True
241243
assert album_1.get('parent').get('name') == 'Nightwish'
242244
assert not album_1.has('title')
243245

@@ -252,6 +254,11 @@ def test_has(): # type: () -> None
252254
assert album.has('bar') is False
253255

254256

257+
def test_existence(): # type: () -> None
258+
album = Album()
259+
assert album.is_existed() is False
260+
261+
255262
def test_get_set_acl(): # type: () -> None
256263
acl = leancloud.ACL()
257264
album = Album()

tests/test_query.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ def test_basic_query(): # type: () -> None
169169
# get
170170
GameScore.query.get(game_score.id)
171171

172+
# get nonexist
173+
assert GameScore.query.get("NonexistentID").is_existed() is False
174+
172175
# count
173176
eq_(GameScore.query.count(), 10)
174177

0 commit comments

Comments
 (0)