GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

RegistrationAutoLoginTestCase   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 77.94 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 53
loc 68
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_no_auto_login_with_setting() 18 18 2
A test_no_auto_login_with_no_password() 19 19 1
A test_auto_login() 16 16 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
# -*- coding: utf-8 -*-
2
from __future__ import unicode_literals
3
"""
4
"""
5
__author__ = 'Alisue <[email protected]>'
6
from django.test import TestCase
7
from django.contrib.auth.models import AnonymousUser
8
from registration.backends.default import DefaultRegistrationBackend
9
from registration.tests.mock import mock_request
10
from registration.tests.compat import override_settings
11
12
13
@override_settings(
14
        ACCOUNT_ACTIVATION_DAYS=7,
15
        REGISTRATION_OPEN=True,
16
        REGISTRATION_SUPPLEMENT_CLASS=None,
17
        REGISTRATION_BACKEND_CLASS=(
18
            'registration.backends.default.DefaultRegistrationBackend'),
19
        REGISTRATION_AUTO_LOGIN=True,
20
        _REGISTRATION_AUTO_LOGIN_IN_TESTS=True,
21
    )
22
class RegistrationAutoLoginTestCase(TestCase):
23
    backend = DefaultRegistrationBackend()
24
    mock_request = mock_request()
25
26 View Code Duplication
    def test_no_auto_login_with_setting(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
27
        """Auto login feature should be able to off with ``REGISTRATION_AUTO_LOGIN = False``"""
28
        self.mock_request.user = AnonymousUser()
29
30
        with override_settings(REGISTRATION_AUTO_LOGIN = False):
31
32
            new_user = self.backend.register(
33
                    'bob', '[email protected]', request=self.mock_request,
34
                )
35
            self.backend.accept(
36
                    new_user.registration_profile, request=self.mock_request,
37
                )
38
            self.backend.activate(
39
                    new_user.registration_profile.activation_key,
40
                    password='password',request=self.mock_request,
41
                )
42
43
            self.failIf(self.mock_request.user.is_authenticated())
44
45 View Code Duplication
    def test_no_auto_login_with_no_password(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
46
        """Auto login feature should not be occur with no password 
47
        (programatically activated by Django Admin action)
48
        
49
        """
50
        self.mock_request.user = AnonymousUser()
51
52
        new_user = self.backend.register(
53
                'bob', '[email protected]', request=self.mock_request,
54
            )
55
        self.backend.accept(
56
                new_user.registration_profile, request=self.mock_request,
57
            )
58
        self.backend.activate(
59
                new_user.registration_profile.activation_key,
60
                request=self.mock_request,
61
            )
62
63
        self.failIf(self.mock_request.user.is_authenticated())
64
65 View Code Duplication
    def test_auto_login(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
66
        """Wheather auto login feature works correctly"""
67
        self.mock_request.user = AnonymousUser()
68
69
        new_user = self.backend.register(
70
                'bob', '[email protected]', request=self.mock_request,
71
            )
72
        self.backend.accept(
73
                new_user.registration_profile, request=self.mock_request,
74
            )
75
        self.backend.activate(
76
                new_user.registration_profile.activation_key,
77
                password='password',request=self.mock_request,
78
            )
79
80
        self.failUnless(self.mock_request.user.is_authenticated())
81