# -*- mode: python -*-
from contextlib import contextmanager
from infinisim.infinibox import Infinibox as Simulator
from infinisdk.infinibox import InfiniBox


@contextmanager
def doctest_context():
    simulator = Simulator()
    for _ in range(3):
        simulator.events.add_user_event(code='VOLUME_CREATED')
        simulator.events.add_user_event(code='VOLUME_DELETED')
    simulator.activate()
    system = InfiniBox(simulator, auth=('infinidat', '123456'))
    system.login()
    try:
        yield {
            "system": system,
        }
    finally:
        simulator.deactivate()
