Passed
Pull Request — master (#49)
by Roman
01:48
created

LocalizedFieldsAdminMixinTestCase.test_model_admin()   A

Complexity

Conditions 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
rs 9.4285
c 1
b 0
f 0
cc 2
1
from django.apps import apps
0 ignored issues
show
Configuration introduced by
The import django.apps 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...
2
from django.contrib import admin
0 ignored issues
show
Configuration introduced by
The import django.contrib 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.contrib.admin.checks import check_admin_app
0 ignored issues
show
Configuration introduced by
The import django.contrib.admin.checks 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...
4
from django.db import models
0 ignored issues
show
Configuration introduced by
The import django.db 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...
5
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...
6
7
from localized_fields.fields import LocalizedField
8
from localized_fields.admin import LocalizedFieldsAdminMixin
9
10
from tests.fake_model import get_fake_model
11
12
13
class LocalizedFieldsAdminMixinTestCase(TestCase):
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
14
    """Tests the :see:LocalizedFieldsAdminMixin class."""
15
16
    TestModel = None
17
    TestRelModel = None
18
19
    @classmethod
20
    def setUpClass(cls):
21
        """Creates the test model in the database."""
22
23
        super(LocalizedFieldsAdminMixinTestCase, cls).setUpClass()
24
25
        cls.TestRelModel = get_fake_model(
26
            {
27
                'description': LocalizedField()
28
            }
29
        )
30
        cls.TestModel = get_fake_model(
31
            {
32
                'title': LocalizedField(),
33
                'rel': models.ForeignKey(cls.TestRelModel,
34
                                         on_delete=models.CASCADE)
35
            }
36
        )
37
38
    def tearDown(self):
39
        if admin.site.is_registered(self.TestModel):
40
            admin.site.unregister(self.TestModel)
41
        if admin.site.is_registered(self.TestRelModel):
42
            admin.site.unregister(self.TestRelModel)
43
44
    @classmethod
45
    def test_model_admin(cls):
46
        """Tests whether :see:LocalizedFieldsAdminMixin
47
        mixin are works with admin.ModelAdmin"""
48
49
        @admin.register(cls.TestModel)
0 ignored issues
show
Unused Code introduced by
The variable TestModelAdmin seems to be unused.
Loading history...
50
        class TestModelAdmin(LocalizedFieldsAdminMixin, admin.ModelAdmin):
51
            pass
52
53
        assert len(check_admin_app(apps.get_app_configs())) == 0
54
55
    @classmethod
56
    def test_stackedmodel_admin(cls):
57
        """Tests whether :see:LocalizedFieldsAdminMixin mixin are works
58
        with admin.StackedInline"""
59
60
        class TestModelStackedInline(LocalizedFieldsAdminMixin,
61
                                     admin.StackedInline):
62
            model = cls.TestModel
63
64
        @admin.register(cls.TestRelModel)
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
Unused Code introduced by
The variable TestRelModelAdmin seems to be unused.
Loading history...
65
        class TestRelModelAdmin(admin.ModelAdmin):
66
            inlines = [
67
                TestModelStackedInline,
68
            ]
69
70
        assert len(check_admin_app(apps.get_app_configs())) == 0
71
72
    @classmethod
73
    def test_tabularmodel_admin(cls):
74
        """Tests whether :see:LocalizedFieldsAdminMixin mixin are works
75
        with admin.TabularInline"""
76
77
        class TestModelTabularInline(LocalizedFieldsAdminMixin,
78
                                     admin.TabularInline):
79
            model = cls.TestModel
80
81
        @admin.register(cls.TestRelModel)
0 ignored issues
show
Coding Style introduced by
This class has no __init__ method.
Loading history...
Unused Code introduced by
The variable TestRelModelAdmin seems to be unused.
Loading history...
82
        class TestRelModelAdmin(admin.ModelAdmin):
83
            inlines = [
84
                TestModelTabularInline,
85
            ]
86
87
        assert len(check_admin_app(apps.get_app_configs())) == 0
88