

def test_save_multiple(self):
    '\n        Test the save_translations() function to store multiple languages.\n        '
    x = SimpleModel()
    x.set_current_language('en')
    x.tr_title = 'TITLE_EN'
    x.set_current_language('fr')
    x.tr_title = 'TITLE_FR'
    x.set_current_language('es')
    x.tr_title = 'TITLE_ES'
    x.set_current_language('nl')
    x.tr_title = 'TITLE_NL'
    x.save()
    self.assertEqual(sorted(x.translations.values_list('tr_title', flat=True)), ['TITLE_EN', 'TITLE_ES', 'TITLE_FR', 'TITLE_NL'])
    self.assertEqual(sorted(x.get_available_languages()), ['en', 'es', 'fr', 'nl'])
    self.assertTrue(x.has_translation('en'))
    self.assertTrue(x.has_translation('es'))
    self.assertFalse(x.has_translation('fi'))
    x.set_current_language('es')
    x.tr_title = 'TITLE_ES2'
    x.set_current_language('nl')
    x.tr_title = 'TITLE_NL2'
    self.assertNumQueries(2, x.save_translations())
    x.set_current_language('it', initialize=True)
    self.assertTrue(x.has_translation('it'))
    self.assertNumQueries(0, x.save_translations())
    self.assertEqual(sorted(x.get_available_languages()), ['en', 'es', 'fr', 'nl'])

dataset/ETHPy150Open edoburu/django-parler/parler/tests/test_model_attributes.py ModelAttributeTests.test_save_multiple/original