@@ -0,0 +1,1732 @@
+# -*- coding: utf-8 -*-%0Aimport copy%0A%0Afrom django.core.cache import cache%0Afrom django.db.models import signals%0Afrom django.test import TestCase%0Afrom django.test.utils import override_settings%0A%0Afrom .. import settings%0Afrom ..models import Translation%0A%0A%0Aclass ModelsTest(TestCase):%0A%0A    def setUp(self):%0A        cache.clear()%0A        self.translation_values = %7B%0A            'identifier': 'post',%0A            'object_id': 1,%0A            'language': 'fr',%0A            'field_name': 'title',%0A            'field_value': 'Bonjour',%0A        %7D%0A%0A    def tearDown(self):%0A        cache.clear()%0A%0A    def test_set_translation(self):%0A        t, c = Translation.objects.set_translation(**self.translation_values)%0A        self.assertTrue(c)%0A        t, c = Translation.objects.set_translation(**self.translation_values)%0A        self.assertFalse(c)%0A%0A    def test_cache_keys(self):%0A        t, c = Translation.objects.set_translation(**self.translation_values)%0A        self.assertTrue(c)%0A        self.assertIn('cache_keys', dir(t))%0A        self.assertIn('_get_cache_keys', dir(t))%0A        self.assertEqual(t.cache_keys, ('linguist_post_1_fr_title', 'linguist_1'))%0A%0A    def test_cache(self):%0A        # get + create = 2%0A        with self.assertNumQueries(2):%0A            t, c = Translation.objects.set_translation(**self.translation_values)%0A%0A        # get id should not hit db%0A        with self.assertNumQueries(0):%0A            t = Translation.objects.get(id=1)%0A%0A        # get id should hit db only once for save%0A        with self.assertNumQueries(1):%0A            t = Translation.objects.get(id=1)%0A            t.field_value = 'blabla'%0A            t.save()%0A            t = Translation.objects.get(id=1)%0A            self.assertEqual(t.field_value, 'blabla')%0A

Add models tests.