Example #1
0
    def testDelayedCreation(self):
        obj = Bar()
        obj.name = 'Bar'
        obj.description = 'Some desc'
        obj.price = 9
        obj.quantity = 2
        obj.save()

        obj2 = Bar.objects.get(pk=obj.pk)
        self.assertEquals(obj2.name, 'Bar')
        self.assertEquals(obj2.description, 'Some desc')
        self.assertEquals(obj2.price , 9)
        self.assertEquals(obj2.quantity , 2)
Example #2
0
    def testCreateTranslationWithoutSaving(self):
        obj = Bar()
        obj.name = 'Bar'
        obj.description = 'Some description'
        obj.price = 10
        obj.quantity = 2

        try:
            obj2 = obj.create_translation(name='Bar2', description='sadfsd',
                price=13, quantity=3, language='fr')
        except InvalidActionError, e:
            self.assertEquals(unicode(e),
                _('Cannot create a translation of an unsaved object.')
            )
Example #3
0
    def testDelayedCreation(self):
        obj = Bar()
        obj.name = 'Bar'
        obj.description = 'Some desc'
        obj.price = 9
        obj.quantity = 2

        translation.activate('fr')
        obj.name = 'BarFr'
        obj.description = 'Some desc fr'
        obj.save()

        translation.activate('en')
        obj = Bar.objects.get(pk=obj.pk)
        self.assertEquals(obj.name, 'Bar')
        self.assertEquals(obj.description, 'Some desc')
        self.assertEquals(obj.price, 9)
        self.assertEquals(obj.quantity, 2)

        translation.activate('fr')
        self.assertEquals(obj.name, 'BarFr')
        self.assertEquals(obj.description, 'Some desc fr')
        self.assertEquals(obj.price, 9)
        self.assertEquals(obj.quantity, 2)