Update get_or_create method

This commit is contained in:
Mojix Coder
2022-02-01 09:44:07 +03:30
parent 4ed267e5c3
commit fc32001fe7
9 changed files with 92 additions and 33 deletions

View File

@ -195,12 +195,14 @@ async def test_queryset_methods():
comps = await Company.objects.all()
assert [comp.saved for comp in comps]
comp2 = await Company.objects.get_or_create(name="Banzai_new", founded=2001)
comp2, created = await Company.objects.get_or_create(name="Banzai_new", founded=2001)
assert comp2.saved
assert created is True
comp3 = await Company.objects.get_or_create(name="Banzai", founded=1988)
comp3, created = await Company.objects.get_or_create(name="Banzai", founded=1988)
assert comp3.saved
assert comp3.pk == comp.pk
assert created is False
update_dict = comp.dict()
update_dict["founded"] = 2010