Skip to content

Commit

Permalink
add juju.get_controllers
Browse files Browse the repository at this point in the history
Fixes juju#529
  • Loading branch information
cderici committed Sep 20, 2021
1 parent dc58076 commit dd639b3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
10 changes: 8 additions & 2 deletions juju/juju.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
from juju.client.jujudata import FileJujuData


class Juju(object):

def __init__(self, jujudata=None):
self.jujudata = jujudata or FileJujuData()

def add_cloud(self, name, definition, replace=False):
"""Add a user-defined cloud to Juju from among known cloud types.
Expand Down Expand Up @@ -58,9 +65,8 @@ def get_clouds(self):
def get_controllers(self):
"""Return list of all available controllers.
(maybe move this to Cloud?)
"""
raise NotImplementedError()
return self.jujudata.controllers()

def get_plans(self, charm_url):
"""Return list of plans available for the specified charm.
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/test_juju.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest

from juju.juju import Juju
from .. import base


@base.bootstrapped
@pytest.mark.asyncio
async def test_get_controllers(event_loop):
async with base.CleanController() as controller:
j = Juju()

controllers = j.get_controllers()
assert isinstance(controllers, dict)
assert len(controllers) >= 1
assert controller.controller_name in controllers

0 comments on commit dd639b3

Please sign in to comment.