Exemplo n.º 1
0
    def setUp(self):
        self.settingsManager.set(MSGID_LANUAGE='en',
                                 FALLBACK_LANGUAGES={'de': ['en-us']})
        gc.collect()
        translation.activate(settings.LANGUAGE_CODE)

        try:
            t = models.TestModel(charfield='Hoi Ik ben de root node')
            t.save()
            f = t.submodels.create(
                subcharfield="Hoi Ik ben de first level sub node",
                subintegerfield=10)
            s = t.submodels.create(
                subcharfield="Hoi ik ben de tweede first level sub node",
                subintegerfield=100)
            w = t.secondsubmodels.create(
                ultrafield="Sed tempor. Ut felis. Maecenas erat.")
            f.subsubmodels.create(
                subsubcharfield="Hoi ik ben de thord level sub node")
            f.subsubmodels.create(
                subsubcharfield="Hoi ik ben de third level sub node")
            s.subsubmodels.create(
                subsubcharfield="Hoi ik ben de third level sub node")
            s.subsubmodels.create(
                subsubcharfield="Hoi ik ben de third level sub node")
            t.save()
        except OSError as e:
            if e.errno == 24:
                print "hai er zit een bug in de mutex"
Exemplo n.º 2
0
    def test_model_to_po(self):
        """A newly created model should be serialized to po"""
        locale_dir = join(settings.LOCALE_DIR, 'locale')
        if isdir(locale_dir):
            shutil.rmtree(locale_dir)

        assert (not isdir(locale_dir))
        i = models.TestModel(charfield='ik word serialized to po')
        i.save()
        assert (isdir(locale_dir))

        result = ffindgrep(locale_dir, ['^msgid "ik word serialized to po"$'])
        assert (result != {})
Exemplo n.º 3
0
    def test_created_property_is_set(self):
        """A signal sent when a model is created should have the created property set to true"""
        def stub(sender, **kwargs):
            self.save_was_caught = True
            self.save_was_a_created = kwargs['created']

        self.save_was_caught = False
        self.save_was_a_created = False

        post_save.connect(stub, models.TestModel)
        i = models.TestModel(charfield='hai mother')
        i.save()
        assert (self.save_was_caught)
        assert (self.save_was_a_created)
Exemplo n.º 4
0
    def test_translation_nomsgid(self):
        """
        When the msgid is None or empty, the value from the fallback language
        should be used.
        """

        # Extra setup
        translation.activate('en-us')
        i = models.TestModel(charfield='Woot, not failed!')
        i.save()
        self.assertTrue(
            i.charfield == getattr(i, 'charfield_en_us') == 'Woot, not failed!'
        )
        translation.activate('de')

        # Test
        self.assertEqual(i.charfield, 'Woot, not failed!')