def engine(dynamodb, dynamodbstreams, request): engine = Engine(dynamodb=dynamodb, dynamodbstreams=dynamodbstreams, table_name_template="{table_name}" + request.config.getoption("--nonce")) yield engine # This collects all subclasses of BaseModel and are not abstract. We are trying to delete any data in # dynamodb-local between unit tests so we don't step on each other's toes. concrete = set( filter(lambda m: not m.Meta.abstract, walk_subclasses(BaseModel))) for model in concrete: # we can run into a situation where the class was created, but not bound in the engine (or table created), so # we only try. As the dynamodb-local process is only running in memory this isn't too much of a problem. try: objs = list(engine.scan(model)) if objs: engine.delete(*objs) except BloopException: pass
def engine(dynamodb, dynamodbstreams): engine = Engine(dynamodb=dynamodb, dynamodbstreams=dynamodbstreams) yield engine engine.delete(*engine.scan(User))