add simple (currently failing) client test
authorTim Van Steenburgh <tvansteenburgh@gmail.com>
Tue, 24 May 2016 14:59:53 +0000 (10:59 -0400)
committerTim Van Steenburgh <tvansteenburgh@gmail.com>
Tue, 24 May 2016 14:59:53 +0000 (10:59 -0400)
.gitignore
juju/client/client.py
juju/client/facade.py
tests/base.py [new file with mode: 0644]
tests/client/test_client.py [new file with mode: 0644]
tests/client/test_connection.py

index 914e120..cd9f273 100644 (file)
@@ -5,3 +5,4 @@ docs/_build/
 __pycache__/
 .tox/
 *.egg-info/
+.cache/
index 9bb3aec..d556d7e 100644 (file)
@@ -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'}
index 7b7d9c7..3e29533 100644 (file)
@@ -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 (file)
index 0000000..35003cb
--- /dev/null
@@ -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 (file)
index 0000000..876470e
--- /dev/null
@@ -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
index 187dcb0..18b5863 100644 (file)
@@ -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