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

MyContainer.update_value()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 2
rs 10
cc 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