File: test_fallback_translation.py

package info (click to toggle)
sqlalchemy-i18n 1.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 396 kB
  • sloc: python: 2,164; makefile: 157
file content (33 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-

from tests import ClassicTestCase, DeclarativeTestCase


class Suite(object):
    def test_as_object_property_with_force_locale(self):
        article = self.Article()
        article.name = u'Some article'
        article.content = u'Some content'
        self.session.add(article)
        self.session.commit()
        assert article.fallback_translation == article.translations['en']

    def test_as_class_property(self):
        assert self.Article.fallback_translation

    def test_setter(self):
        article = self.Article()
        article.fallback_translation = self.Article.__translatable__['class'](
            name=u'Something'
        )
        self.session.add(article)
        self.session.commit()
        assert article.name == u'Something'


class TestDeclarative(Suite, DeclarativeTestCase):
    pass


class TestClassic(Suite, ClassicTestCase):
    pass