382da4362413291a218f83d6885724b7ff2ad9fd
6 from juju
.controller
import Controller
10 result
= subprocess
.run(['juju', 'switch'], stdout
=subprocess
.PIPE
)
12 result
.returncode
== 0 and
13 len(result
.stdout
.decode().strip()) > 0)
15 bootstrapped
= pytest
.mark
.skipif(
16 not is_bootstrapped(),
17 reason
='bootstrapped Juju environment required')
22 self
.controller
= None
25 async def __aenter__(self
):
26 self
.controller
= Controller()
27 await self
.controller
.connect_current()
29 model_name
= 'model-{}'.format(uuid
.uuid4())
30 self
.model
= await self
.controller
.add_model(model_name
)
34 async def __aexit__(self
, exc_type
, exc
, tb
):
35 await self
.model
.disconnect()
36 await self
.controller
.destroy_model(self
.model
.info
.uuid
)
37 await self
.controller
.disconnect()