# Path: huacaya/storage/base.py
# class BucketBase(object):
#     def drop(self):
#         raise NotImplementedError
# 
#     def put(self, entity):
#         raise NotImplementedError
# 
#     def get(self, stub):
#         raise NotImplementedError
# 
#     def delete(self, stub):
#         raise NotImplementedError
# 
#     def update(self, entity):
#         raise NotImplementedError
# 
#     def __contains__(self, item):
#         raise NotImplementedError
# 
#     def __getitem__(self, item):
#         return self.get(item)
# 
# class StorageBase(object):
#     def create_bucket(self, name, index=()):
#         raise NotImplementedError
# 
#     def get_bucket(self, name):
#         raise NotImplementedError
# 
#     def drop(self, bucket):
#         raise NotImplementedError
# 
#     def __contains__(self, item):
#         raise NotImplementedError
# 
#     def __getitem__(self, item):
#         return self.get_bucket(item)


from .base import BucketBase, StorageBase
from time import mktime
import json
import datetime
import base64
import sqlite3
            if set(fields.items()).issubset(set(v.items())):
                yield k, v

    def find_one(self, fields):
        for k, v in self.items():
            if set(fields.items()).issubset(set(v.items())):
                return k, v
        return None

    def __getitem__(self, item):
        return self.get_object(item)

    def __contains__(self, item):
        sql = 'SELECT COUNT(id) FROM {0} WHERE k=?'.format(self._name)
        return self._db.cursor().execute(sql, (item, )).fetchone()[0] > 0

    def __iter__(self):
        sql = 'SELECT k FROM {0}'.format(self._name)
        for row in self._db.cursor().execute(sql):
            yield row[0]

    def keys(self):
        return list(self)

    def items(self):
        sql = 'SELECT k, v FROM {0}'.format(self._name)
        for row in self._db.cursor().execute(sql):
            yield row[0], _loads(row[1])



# Path: huacaya/storage/base.py
# class BucketBase(object):
#     def drop(self):
#         raise NotImplementedError
# 
#     def put(self, entity):
#         raise NotImplementedError
# 
#     def get(self, stub):
#         raise NotImplementedError
# 
#     def delete(self, stub):
#         raise NotImplementedError
# 
#     def update(self, entity):
#         raise NotImplementedError
# 
#     def __contains__(self, item):
#         raise NotImplementedError
# 
#     def __getitem__(self, item):
#         return self.get(item)
# 
# class StorageBase(object):
#     def create_bucket(self, name, index=()):
#         raise NotImplementedError
# 
#     def get_bucket(self, name):
#         raise NotImplementedError
# 
#     def drop(self, bucket):
#         raise NotImplementedError
# 
#     def __contains__(self, item):
#         raise NotImplementedError
# 
#     def __getitem__(self, item):
#         return self.get_bucket(item)


# Path: huacaya/storage/mock.py
from .base import BucketBase, StorageBase
from time import mktime
import json
import datetime
import base64
import sqlite3

            if set(fields.items()).issubset(set(v.items())):
                yield k, v

    def find_one(self, fields):
        for k, v in self.items():
            if set(fields.items()).issubset(set(v.items())):
                return k, v
        return None

    def __getitem__(self, item):
        return self.get_object(item)

    def __contains__(self, item):
        sql = 'SELECT COUNT(id) FROM {0} WHERE k=?'.format(self._name)
        return self._db.cursor().execute(sql, (item, )).fetchone()[0] > 0

    def __iter__(self):
        sql = 'SELECT k FROM {0}'.format(self._name)
        for row in self._db.cursor().execute(sql):
            yield row[0]

    def keys(self):
        return list(self)

    def items(self):
        sql = 'SELECT k, v FROM {0}'.format(self._name)
        for row in self._db.cursor().execute(sql):
            yield row[0], _loads(row[1])



class MockStorage(StorageBase):