def test_not_implemented(self, init): r = ReadOnlyStorage() self.assertRaises(NotImplementedError, lambda: r.record()) self.assertRaises(NotImplementedError, lambda: r.store(None, None))
class Storage(StorageInterface): def __init__(self): super().__init__() self.storage = None # defaults to ReadOnlyStorage def cancer(self): if not self.storage: from twitchcancer.storage.readonlystorage import ReadOnlyStorage self.storage = ReadOnlyStorage() return self.storage.cancer() # defaults to ReadOnlyStorage def leaderboards(self, horizon): if not self.storage: from twitchcancer.storage.readonlystorage import ReadOnlyStorage self.storage = ReadOnlyStorage() return self.storage.leaderboards(horizon) # defaults to ReadOnlyStorage def leaderboard(self, name): if not self.storage: from twitchcancer.storage.readonlystorage import ReadOnlyStorage self.storage = ReadOnlyStorage() return self.storage.leaderboard(name) # defaults to ReadOnlyStorage def channel(self, channel): if not self.storage: from twitchcancer.storage.readonlystorage import ReadOnlyStorage self.storage = ReadOnlyStorage() return self.storage.channel(channel) # defaults to ReadOnlyStorage def status(self): if not self.storage: from twitchcancer.storage.readonlystorage import ReadOnlyStorage self.storage = ReadOnlyStorage() return self.storage.status() # defaults to MemoryStorage def store(self, channel, cancer): # messages are stored in-memory only if not self.storage: from twitchcancer.storage.memorystorage import MemoryStorage self.storage = MemoryStorage() self.storage.store(channel, cancer) # defaults to WriteOnlyStorage def record(self): # summaries are written to the database if not self.storage: from twitchcancer.storage.writeonlystorage import WriteOnlyStorage self.storage = WriteOnlyStorage() self.storage.record() # defaults to ReadOnlyStorage def search(self, channel): if not self.storage: from twitchcancer.storage.readonlystorage import ReadOnlyStorage self.storage = ReadOnlyStorage() return self.storage.search(channel)