Coverage for src/counter_os/infrastructure/persistence/in_memory_counter_repository.py: 100%
18 statements
« prev ^ index » next coverage.py v7.17.5, created at 2026-11-29 05:31 -0600
« prev ^ index » next coverage.py v7.17.5, created at 2026-11-29 05:31 -0600
1import copy
2from dataclasses import dataclass
4from counter_os.domain.entities.counter import Counter
5from counter_os.domain.repositories.counter_repository import CounterRepository
6from counter_os.domain.value_objects.count import Count
7from counter_os.infrastructure.persistence.counter_repository_type import (
8 CounterRepositoryType,
9)
12@dataclass
13class InMemoryCounterRepository(CounterRepository):
14 def __post_init__(self):
15 self._counter = Counter(Count(0))
17 def save(self, counter: Counter):
18 self._counter = copy.deepcopy(counter)
20 def get(self) -> Counter:
21 return self._counter
23 def repository_type(self) -> str:
24 return CounterRepositoryType.MEMORY
26 def repository_location(self) -> str:
27 return "RAM"