Passed
Pull Request — master (#259)
by Piotr
01:20
created

test_valid_token_delete_without_trailing_slash()   A

Complexity

Conditions 4

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
c 1
b 0
f 0
dl 17
loc 17
rs 9.2
1
import pytest
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
introduced by
Unable to import 'pytest'
Loading history...
2
3
from django.contrib.auth import get_user_model
4
from rest_framework import status
5
from rest_framework.test import APIClient
6
7
User = get_user_model()
0 ignored issues
show
Coding Style Naming introduced by
The name User does not conform to the constant naming conventions ((([A-Z_][A-Z0-9_]*)|(__.*__))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
8
9
10 View Code Duplication
@pytest.mark.django_db(transaction=False)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11
def test_valid_token_delete_with_trailing_slash(test_user, settings):
0 ignored issues
show
Coding Style Naming introduced by
The name test_valid_token_delete_with_trailing_slash does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
12
    from djoser.conf import settings as djoser_settings
13
14
    settings.DJOSER = dict(
15
        settings.DJOSER,
16
        **{'TOKEN_MODEL': 'rest_framework.authtoken.models.Token'}
17
    )
18
    token, _ = djoser_settings.TOKEN_MODEL.objects.get_or_create(
0 ignored issues
show
Unused Code introduced by
The variable token seems to be unused.
Loading history...
19
        user=test_user
20
    )
21
    assert djoser_settings.TOKEN_MODEL.objects.count() == 1
22
23
    client = APIClient()
24
    client.force_login(test_user)
25
    response = client.delete('/token/')
26
27
    assert response.status_code == status.HTTP_204_NO_CONTENT
28
    assert djoser_settings.TOKEN_MODEL.objects.count() == 0
29
30
31 View Code Duplication
@pytest.mark.django_db(transaction=False)
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
32
def test_valid_token_delete_without_trailing_slash(test_user, settings):
0 ignored issues
show
Coding Style Naming introduced by
The name test_valid_token_delete_without_trailing_slash does not conform to the function naming conventions ((([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Coding Style introduced by
This function should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
33
    from djoser.conf import settings as djoser_settings
34
35
    settings.DJOSER = dict(
36
        settings.DJOSER,
37
        **{'TOKEN_MODEL': 'rest_framework.authtoken.models.Token'}
38
    )
39
    djoser_settings.TOKEN_MODEL.objects.get_or_create(user=test_user)
40
    assert djoser_settings.TOKEN_MODEL.objects.count() == 1
41
42
    client = APIClient()
43
    client.force_login(test_user)
44
    response = client.delete('/token')
45
46
    assert response.status_code == status.HTTP_204_NO_CONTENT
47
    assert djoser_settings.TOKEN_MODEL.objects.count() == 0
48