| Total Lines | 32 |
| Duplicated Lines | 0 % |
| 1 | # pylint: disable=missing-docstring,no-self-use,misplaced-comparison-constant,abstract-class-instantiated |
||
| 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 |