bump version, more tests, update docs

This commit is contained in:
collerek
2020-12-06 19:45:09 +01:00
parent 420826f472
commit 9f86e1d46e
10 changed files with 419 additions and 44 deletions

View File

@ -0,0 +1,22 @@
from ormar import pre_update
@pre_update(Album)
async def before_update(sender, instance, **kwargs):
if instance.play_count > 50 and not instance.is_best_seller:
instance.is_best_seller = True
# here album.play_count ans is_best_seller get default values
album = await Album.objects.create(name="Venice")
assert not album.is_best_seller
assert album.play_count == 0
album.play_count = 30
# here a trigger is called but play_count is too low
await album.update()
assert not album.is_best_seller
album.play_count = 60
await album.update()
assert album.is_best_seller