Example #1
0
    def test_create_translations(self):

        self.populate(self.session)

        language = self.session.query(Language).\
                        filter(Language.lang==u'en').one()
        language.enabled = False

        src_language = self.session.query(Language).\
                            filter(Language.lang==u'it').one()
        dst_language = self.session.query(Language).\
                            filter(Language.lang==u'de').one()

        dst_language.enabled = True

        translations = NodeInfo.create_translations(self.session,
                                                    src_language.id,
                                                    dst_language)

        original = self.session.query(NodeInfo).\
                        filter(NodeInfo.lang.has(id=src_language.id)).count()
        self.assertEqual(len(translations), original)

        original = self.session.query(NodeInfo).\
                        filter(NodeInfo.lang.has(id=language.id)).count()
        self.assertEqual(len(translations), original)
Example #2
0
    def test_remove_translations(self):

        self.populate(self.session)

        language = self.session.query(Language).\
                        filter(Language.lang==u'it').one()
        language.enabled = False

        removed = NodeInfo.remove_translations(self.session, language.id)
        self.assertNotEqual(removed, 0)

        translations = self.session.query(NodeInfo).\
                            filter(NodeInfo.lang.has(id=language.id)).count()
        self.assertEqual(translations, 0)