Completed
Push — develop ( 3bb0e5...9a26e8 )
by Jace
08:11
created

  A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
dl 0
loc 31
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A yContainer.create_default() 0 3 1
A yContainer.__init__() 0 4 1
A estContainer.test_container_instance_methods_can_be_called() 0 6 4
A estContainer.test_container_class_cannot_be_instantiated() 0 3 2
A yContainer.to_data() 0 3 1
A yContainer.update_value() 0 2 1
1
# pylint: disable=missing-docstring,no-self-use,misplaced-comparison-constant,abstract-class-instantiated
0 ignored issues
show
introduced by
Bad option value 'misplaced-comparison-constant'
Loading history...
2
3
import pytest
4
5
from yorm.bases import Container
6
7
8
class TestContainer:
9
    """Unit tests for the `Container` class."""
10
11
    class MyContainer(Container):
12
13
        def __init__(self, number):
14
            from unittest.mock import MagicMock
15
            self.__mapper__ = MagicMock()
16
            self.value = number
17
18
        @classmethod
19
        def create_default(cls):
20
            return 1
21
22
        @classmethod
23
        def to_data(cls, value):
24
            return str(value.value)
25
26
        def update_value(self, data, *, auto_track=None):  # pylint: disable=unused-variable
27
            self.value += int(data)
28
29
    def test_container_class_cannot_be_instantiated(self):
30
        with pytest.raises(TypeError):
31
            Container()
32
33
    def test_container_instance_methods_can_be_called(self):
34
        container = self.MyContainer(42)
35
        assert 42 == container.value
36
        container.update_value(10)
37
        assert 52 == container.value
38
        assert "52" == container.format_data()
39