Passed
Push — master ( 5e58bc...04f153 )
by Swen
01:51
created

LocalizedQuerySetTestCase   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_assign_raw_dict_update() 0 11 3
A test_assign_raw_dict() 0 9 3
A setUpClass() 0 9 1
1
from django.conf import settings
0 ignored issues
show
Configuration introduced by
The import django.conf could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
Unused Code introduced by
Unused settings imported from django.conf
Loading history...
2
from django.test import TestCase
0 ignored issues
show
Configuration introduced by
The import django.test could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
3
from django.utils import translation
0 ignored issues
show
Configuration introduced by
The import django.utils could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
Unused Code introduced by
Unused translation imported from django.utils
Loading history...
4
5
from localized_fields.fields import LocalizedField
6
7
from .fake_model import get_fake_model
8
9
10
class LocalizedQuerySetTestCase(TestCase):
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
11
    """Tests query sets with models containing :see:LocalizedField."""
12
13
    Model = None
14
15
    @classmethod
16
    def setUpClass(cls):
17
        """Creates the test models in the database."""
18
19
        super(LocalizedQuerySetTestCase, cls).setUpClass()
20
21
        cls.Model = get_fake_model(
22
            {
23
                'title': LocalizedField(),
24
            }
25
        )
26
27
    @classmethod
28
    def test_assign_raw_dict(cls):
29
        inst = cls.Model()
30
        inst.title = dict(en='Bread', ro='Paine')
31
        inst.save()
32
33
        inst = cls.Model.objects.get(pk=inst.pk)
34
        assert inst.title.en == 'Bread'
35
        assert inst.title.ro == 'Paine'
36
37
    @classmethod
38
    def test_assign_raw_dict_update(cls):
39
        inst = cls.Model.objects.create(
40
            title=dict(en='Bread', ro='Paine'))
41
42
        cls.Model.objects.update(
43
            title=dict(en='Beer', ro='Bere'))
44
45
        inst = cls.Model.objects.get(pk=inst.pk)
46
        assert inst.title.en == 'Beer'
47
        assert inst.title.ro == 'Bere'
48