From: Tim Van Steenburgh Date: Tue, 24 May 2016 14:59:53 +0000 (-0400) Subject: add simple (currently failing) client test X-Git-Tag: 0.1.0~97 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=f3cc1159b22f570b9b82c62cf7f4cfef9278bac4;p=osm%2FN2VC.git add simple (currently failing) client test --- diff --git a/.gitignore b/.gitignore index 914e120..cd9f273 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ docs/_build/ __pycache__/ .tox/ *.egg-info/ +.cache/ diff --git a/juju/client/client.py b/juju/client/client.py index 9bb3aec..d556d7e 100644 --- a/juju/client/client.py +++ b/juju/client/client.py @@ -1,5 +1,5 @@ -from libjuju.facade import Type, ReturnMapping +from juju.client.facade import Type, ReturnMapping class Action(Type): _toSchema = {'name': 'name', 'receiver': 'receiver', 'parameters': 'parameters', 'tag': 'tag'} diff --git a/juju/client/facade.py b/juju/client/facade.py index 7b7d9c7..3e29533 100644 --- a/juju/client/facade.py +++ b/juju/client/facade.py @@ -518,7 +518,7 @@ def generate_facacdes(options): schemas = json.loads(Path(options.schema).read_text("utf-8")) capture = codegen.CodeWriter() capture.write(""" -from libjuju.facade import Type, ReturnMapping +from juju.client.facade import Type, ReturnMapping """) schemas = [Schema(s) for s in schemas] diff --git a/tests/base.py b/tests/base.py new file mode 100644 index 0000000..35003cb --- /dev/null +++ b/tests/base.py @@ -0,0 +1,14 @@ +import subprocess + +import pytest + + +def is_bootstrapped(): + result = subprocess.run(['juju', 'switch'], stdout=subprocess.PIPE) + return ( + result.returncode == 0 and + len(result.stdout.decode().strip()) > 0) + +bootstrapped = pytest.mark.skipif( + not is_bootstrapped(), + reason='bootstrapped Juju environment required') diff --git a/tests/client/test_client.py b/tests/client/test_client.py new file mode 100644 index 0000000..876470e --- /dev/null +++ b/tests/client/test_client.py @@ -0,0 +1,22 @@ +import asyncio +import unittest + +from juju.client.connection import Connection +from juju.client.client import UserManager, Entity + +from ..base import bootstrapped + + +@bootstrapped +class UserManagerTest(unittest.TestCase): + def test_connect_current(self): + loop = asyncio.get_event_loop() + conn = loop.run_until_complete( + Connection.connect_current()) + + um = UserManager() + um.connect(conn) + result = loop.run_until_complete( + um.UserInfo([Entity('user-admin')], True)) + + assert result diff --git a/tests/client/test_connection.py b/tests/client/test_connection.py index 187dcb0..18b5863 100644 --- a/tests/client/test_connection.py +++ b/tests/client/test_connection.py @@ -1,22 +1,8 @@ import asyncio import unittest -import subprocess - -import pytest from juju.client.connection import Connection - - -def is_bootstrapped(): - result = subprocess.run(['juju', 'switch'], stdout=subprocess.PIPE) - print(result.stdout) - return ( - result.returncode == 0 and - len(result.stdout.decode().strip()) > 0) - -bootstrapped = pytest.mark.skipif( - not is_bootstrapped(), - reason='bootstrapped Juju environment required') +from ..base import bootstrapped @bootstrapped