5 from juju
.controller
import Controller
7 from ..base
import bootstrapped
15 self
.controller
= None
18 async def __aenter__(self
):
19 self
.controller
= Controller()
20 await self
.controller
.connect_current()
22 model_name
= 'model-{}'.format(uuid
.uuid4())
23 self
.model
= await self
.controller
.add_model(model_name
)
27 async def __aexit__(self
, exc_type
, exc
, tb
):
28 await self
.model
.disconnect()
29 await self
.controller
.destroy_model(self
.model
.info
.uuid
)
30 await self
.controller
.disconnect()
35 async def test_add_machine(event_loop
):
36 from juju
.machine
import Machine
38 async with
CleanModel() as model
:
39 # add a new default machine
40 machine1
= await model
.add_machine()
42 # add a machine with constraints, disks, and series
43 machine2
= await model
.add_machine(
55 # add a lxd container to machine2
56 machine3
= await model
.add_machine(
57 'lxd:{}'.format(machine2
.id))
59 for m
in (machine1
, machine2
, machine3
):
60 assert isinstance(m
, Machine
)
62 assert len(model
.machines
) == 3