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

1import copy 

2from dataclasses import dataclass 

3 

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) 

10 

11 

12@dataclass 

13class InMemoryCounterRepository(CounterRepository): 

14 def __post_init__(self): 

15 self._counter = Counter(Count(0)) 

16 

17 def save(self, counter: Counter): 

18 self._counter = copy.deepcopy(counter) 

19 

20 def get(self) -> Counter: 

21 return self._counter 

22 

23 def repository_type(self) -> str: 

24 return CounterRepositoryType.MEMORY 

25 

26 def repository_location(self) -> str: 

27 return "RAM"