TestUserApi.test_get_one()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 10
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nop 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
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...
2
import pytest
0 ignored issues
show
introduced by
Unable to import 'pytest'
Loading history...
3
from sqlalchemy.orm.exc import NoResultFound
4
5
import transaction
6
7
from tracim.lib.core.user import UserApi
8
from tracim.tests import DefaultTest
9
from tracim.tests import eq_
10
11
12
class TestUserApi(DefaultTest):
0 ignored issues
show
Coding Style introduced by
This class 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...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
13
14
    def test_create_and_update_user(self):
0 ignored issues
show
Coding Style introduced by
This method 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...
15
        api = UserApi(
16
            current_user=None,
17
            session=self.session,
18
            config=self.config,
19
        )
20
        u = api.create_user()
0 ignored issues
show
Coding Style Naming introduced by
The name u does not conform to the variable 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...
21
        api.update(u, 'bob', 'bob@bob', True)
22
23
        nu = api.get_one_by_email('bob@bob')
0 ignored issues
show
Coding Style Naming introduced by
The name nu does not conform to the variable 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...
24
        assert nu != None
25
        eq_('bob@bob', nu.email)
26
        eq_('bob', nu.display_name)
27
28
    def test_user_with_email_exists(self):
0 ignored issues
show
Coding Style introduced by
This method 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...
29
        api = UserApi(
30
            current_user=None,
31
            session=self.session,
32
            config=self.config,
33
        )
34
        u = api.create_user()
0 ignored issues
show
Coding Style Naming introduced by
The name u does not conform to the variable 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...
35
        api.update(u, 'bibi', 'bibi@bibi', True)
36
        transaction.commit()
37
38
        eq_(True, api.user_with_email_exists('bibi@bibi'))
39
        eq_(False, api.user_with_email_exists('unknown'))
40
41
    def test_get_one_by_email(self):
0 ignored issues
show
Coding Style introduced by
This method 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...
42
        api = UserApi(
43
            current_user=None,
44
            session=self.session,
45
            config=self.config,
46
        )
47
        u = api.create_user()
0 ignored issues
show
Coding Style Naming introduced by
The name u does not conform to the variable 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...
48
        api.update(u, 'bibi', 'bibi@bibi', True)
49
        uid = u.user_id
50
        transaction.commit()
51
52
        eq_(uid, api.get_one_by_email('bibi@bibi').user_id)
53
54
    def test_get_one_by_email_exception(self):
0 ignored issues
show
Coding Style introduced by
This method 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...
55
        api = UserApi(
56
            current_user=None,
57
            session=self.session,
58
            config=self.config,
59
        )
60
        with pytest.raises(NoResultFound):
61
            api.get_one_by_email('unknown')
62
63
    def test_get_all(self):
0 ignored issues
show
Coding Style introduced by
This method 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...
64
        # TODO - G.M - 29-03-2018 Check why this method is not enabled
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
65
        api = UserApi(
0 ignored issues
show
Unused Code introduced by
The variable api seems to be unused.
Loading history...
66
            current_user=None,
67
            session=self.session,
68
            config=self.config,
69
        )
70
        # u1 = api.create_user(True)
71
        # u2 = api.create_user(True)
72
73
        # users = api.get_all()
74
        # ok_(2==len(users))
75
76
    def test_get_one(self):
0 ignored issues
show
Coding Style introduced by
This method 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...
77
        api = UserApi(
78
            current_user=None,
79
            session=self.session,
80
            config=self.config,
81
        )
82
        u = api.create_user()
0 ignored issues
show
Coding Style Naming introduced by
The name u does not conform to the variable 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...
83
        api.update(u, 'titi', 'titi@titi', True)
84
        one = api.get_one(u.user_id)
85
        eq_(u.user_id, one.user_id)
86