add more test with alternative column names
This commit is contained in:
@ -133,3 +133,25 @@ async def test_bulk_operations_and_fields():
|
||||
await children[0].load()
|
||||
await children[0].delete()
|
||||
children = await Child.objects.all()
|
||||
assert len(children) == 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_working_with_aliases_get_or_create():
|
||||
async with database:
|
||||
async with database.transaction(force_rollback=True):
|
||||
artist = await Artist.objects.get_or_create(first_name='Teddy', last_name='Bear', born_year=2020)
|
||||
assert artist.pk is not None
|
||||
|
||||
artist2 = await Artist.objects.get_or_create(first_name='Teddy', last_name='Bear', born_year=2020)
|
||||
assert artist == artist2
|
||||
|
||||
art3 = artist2.dict()
|
||||
art3['born_year'] = 2019
|
||||
await Artist.objects.update_or_create(**art3)
|
||||
|
||||
artist3 = await Artist.objects.get(last_name='Bear')
|
||||
assert artist3.born_year == 2019
|
||||
|
||||
artists = await Artist.objects.all()
|
||||
assert len(artists) == 1
|
||||
|
||||
Reference in New Issue
Block a user