Completed
Push — develop ( b4a21c...b1df34 )
by Jace
02:37
created

MyContainer.update_value()   A

Complexity

Conditions 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
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
10
    """Unit tests for the `Container` class."""
11
12
    class MyContainer(Container):
13
14
        def __init__(self, number):
15
            from unittest.mock import MagicMock
16
            self.__mapper__ = MagicMock()
17
            self.value = number
18
19
        @classmethod
20
        def create_default(cls):
21
            return 1
22
23
        @classmethod
24
        def to_data(cls, value):
25
            return str(value.value)
26
27
        def update_value(self, data, strict=True):
28
            self.value += int(data)
29
30
    def test_container_class_cannot_be_instantiated(self):
31
        with pytest.raises(TypeError):
32
            Container()
33
34
    def test_container_instance_methods_can_be_called(self):
35
        container = self.MyContainer(42)
36
        assert 42 == container.value
37
        container.update_value(10)
38
        assert 52 == container.value
39
        assert "52" == container.format_data()
40