# -*- mode: python -*-
from contextlib import contextmanager

from capacity import GiB, TiB

from infinisdk import InfiniBox
from infinisim.infinibox import Infinibox as Simulator


@contextmanager
def doctest_context():
    simulator = Simulator()
    pool = simulator.pools.create("pool", physical_capacity=TiB, virtual_capacity=TiB)
    for i in range(5):
        simulator.volumes.create(pool=pool, name="vol{}".format(i), size=GiB)
    simulator.activate()
    system = InfiniBox(simulator, auth=('infinidat', '123456'))
    system.login()
    try:
        yield {
            "system": system,
        }
    finally:
        simulator.deactivate()
