tracim.fixtures   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 29
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 9

5 Methods

Rating   Name   Duplication   Size   Complexity  
A FixturesLoader._load() 0 10 2
A FixturesLoader.__init__() 0 5 2
A Fixture.__init__() 0 3 1
A Fixture.insert() 0 2 1
A FixturesLoader.loads() 0 5 3
1
import transaction
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
3
4
class Fixture(object):
0 ignored issues
show
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
5
6
    """ Fixture classes (list) required for this fixtures"""
7
    require = NotImplemented
8
9
    def __init__(self, session, config):
10
        self._session = session
11
        self._config = config
12
13
    def insert(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...
14
        raise NotImplementedError()
15
16
17
class FixturesLoader(object):
0 ignored issues
show
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
18
    """
19
    Fixtures loader. Load each fixture once.
20
    """
21
22
    def __init__(self, session, config, loaded=None):
23
        loaded = [] if loaded is None else loaded
24
        self._loaded = loaded
25
        self._session = session
26
        self._config = config
27
28
    def loads(self, fixtures_classes):
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
        for fixture_class in fixtures_classes:
30
            for required_fixture_class in fixture_class.require:
31
                self._load(required_fixture_class)
32
            self._load(fixture_class)
33
34
    def _load(self, fixture_class: Fixture):
35
        if fixture_class not in self._loaded:
36
            fixture = fixture_class(
37
                session=self._session,
38
                config=self._config,
39
            )
40
            fixture.insert()
41
            self._loaded.append(fixture_class)
42
            self._session.flush()
43
            transaction.commit()
44