Skip to content

Commit

Permalink
chore: Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
last-partizan committed May 30, 2023
1 parent a78ae37 commit d315a90
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions modeltranslation/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,35 +467,23 @@ def test_update_or_create_existing(self):
"""
Test that update_or_create works as expected
"""
# Create new object
obj = models.TestModel.objects.create(title_de='old de', title_en='old en')

# Update existing object
instance, created = models.TestModel.objects.update_or_create(
pk=obj.pk, defaults={'title': 'NEW DE TITLE'}
)
assert created is False
assert instance.title == 'NEW DE TITLE'
assert instance.title_en == 'old en'
assert instance.title_de == 'NEW DE TITLE'

# Check that the translation fields are correctly saved and provide the
# correct value when retrieving them again.
instance.refresh_from_db()
assert created is False
assert instance.title == 'NEW DE TITLE'
assert instance.title_en == 'old en'
assert instance.title_de == 'NEW DE TITLE'

def test_update_or_create_new(self):
# Create new object
instance, created = models.TestModel.objects.update_or_create(
title_de='old de', title_en='old en'
pk=1, defaults={'title_de': 'old de', 'title_en': 'old en'},
)

# Check that the translation fields are correctly saved and provide the
# correct value when retrieving them again.
assert created is True
instance.refresh_from_db()
assert instance.title == 'old de'
assert instance.title_en == 'old en'
assert instance.title_de == 'old de'
Expand Down

0 comments on commit d315a90

Please sign in to comment.