Completed
Push — master ( 0bffe1...d6203d )
by Diederik van der
11s
created

parler.tests.AdminTests   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %
Metric Value
dl 0
loc 16
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A AdminTests.test_list_label() 0 4 1
A AdminTests.test_list_label_abc() 0 6 1
1
from __future__ import unicode_literals
2
try:
3
    from django.contrib.admin.utils import label_for_field
4
except ImportError:
5
    from django.contrib.admin.util import label_for_field
6
from .utils import AppTestCase
7
from .testapp.models import SimpleModel, ConcreteModel, AbstractModel
8
9
10
class AdminTests(AppTestCase):
11
    """
12
    Test admin features
13
    """
14
15
    def test_list_label(self):
16
        # See that adding a field to the admin list_display also receives the translated title
17
        # This happens by TranslatedFieldDescriptor.short_description
18
        self.assertEqual(label_for_field('tr_title', SimpleModel), "Translated Title")
19
20
    def test_list_label_abc(self):
21
        # See that the TranslatedFieldDescriptor of the concrete model properly routes to the proper model
22
        self.assertEqual(label_for_field('tr_title', ConcreteModel), "Translated Title")
23
24
        # See that the TranslatedFieldDescriptor of the abstract model handles the fallback properly.
25
        self.assertEqual(label_for_field('tr_title', AbstractModel), "Tr title")
26