Skip to content

Commit 3d0a62c

Browse files
committed
bring across abstract repo with .seen stuff from chap 6/7
1 parent 5717d78 commit 3d0a62c

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎src/allocation/adapters/repository.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1+
from typing import Set
12
import abc
23
from allocation.domain import model
34

45

56
class AbstractRepository(abc.ABC):
6-
@abc.abstractmethod
7+
def __init__(self):
8+
self.seen = set() # type: Set[model.Batch]
9+
710
def add(self, batch: model.Batch):
8-
raise NotImplementedError
11+
self.seen.add(batch)
912

10-
@abc.abstractmethod
1113
def get(self, reference) -> model.Batch:
14+
p = self._get(reference)
15+
if p:
16+
self.seen.add(p)
17+
return p
18+
19+
@abc.abstractmethod
20+
def _get(self, sku):
1221
raise NotImplementedError
1322

1423

0 commit comments

Comments
 (0)