2022-03-11 20:38:12 +01:00
|
|
|
# standard imports
|
|
|
|
import tempfile
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
# external imports
|
|
|
|
from shep.store.file import SimpleFileStoreFactory
|
|
|
|
|
|
|
|
# local imports
|
|
|
|
from chainqueue import (
|
|
|
|
Store,
|
|
|
|
Status,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-03-12 09:48:19 +01:00
|
|
|
class MockContentStore:
|
2022-03-11 20:38:12 +01:00
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.store = {}
|
|
|
|
|
|
|
|
|
|
|
|
def put(self, k, v):
|
|
|
|
self.store[k] = v
|
|
|
|
|
|
|
|
|
|
|
|
def get(self, k):
|
|
|
|
return self.store.get(k)
|
|
|
|
|
|
|
|
|
2022-03-12 09:48:19 +01:00
|
|
|
class MockCounter:
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.c = 0
|
|
|
|
|
|
|
|
|
|
|
|
def next(self):
|
|
|
|
c = self.c
|
|
|
|
self.c += 1
|
|
|
|
return c
|
|
|
|
|
|
|
|
|
2022-03-11 20:38:12 +01:00
|
|
|
class TestShepBase(unittest.TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
self.path = tempfile.mkdtemp()
|
|
|
|
factory = SimpleFileStoreFactory(self.path).add
|
|
|
|
self.state = Status(factory)
|
2022-03-12 09:48:19 +01:00
|
|
|
content_store = MockContentStore()
|
|
|
|
counter = MockCounter()
|
|
|
|
self.store = Store(self.state, content_store, counter)
|