Skip to content

Commit d315a90

Browse files
committed
chore: Update tests
1 parent a78ae37 commit d315a90

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

modeltranslation/tests/tests.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -467,35 +467,23 @@ def test_update_or_create_existing(self):
467467
"""
468468
Test that update_or_create works as expected
469469
"""
470-
# Create new object
471470
obj = models.TestModel.objects.create(title_de='old de', title_en='old en')
472471

473-
# Update existing object
474472
instance, created = models.TestModel.objects.update_or_create(
475473
pk=obj.pk, defaults={'title': 'NEW DE TITLE'}
476474
)
477-
assert created is False
478-
assert instance.title == 'NEW DE TITLE'
479-
assert instance.title_en == 'old en'
480-
assert instance.title_de == 'NEW DE TITLE'
481475

482-
# Check that the translation fields are correctly saved and provide the
483-
# correct value when retrieving them again.
484-
instance.refresh_from_db()
476+
assert created is False
485477
assert instance.title == 'NEW DE TITLE'
486478
assert instance.title_en == 'old en'
487479
assert instance.title_de == 'NEW DE TITLE'
488480

489481
def test_update_or_create_new(self):
490-
# Create new object
491482
instance, created = models.TestModel.objects.update_or_create(
492-
title_de='old de', title_en='old en'
483+
pk=1, defaults={'title_de': 'old de', 'title_en': 'old en'},
493484
)
494485

495-
# Check that the translation fields are correctly saved and provide the
496-
# correct value when retrieving them again.
497486
assert created is True
498-
instance.refresh_from_db()
499487
assert instance.title == 'old de'
500488
assert instance.title_en == 'old en'
501489
assert instance.title_de == 'old de'

0 commit comments

Comments
 (0)