Update docs requirement to fix RTD build
[osm/N2VC.git] / tests / integration / test_connection.py
index 67dfb2e..290203d 100644 (file)
@@ -1,3 +1,4 @@
+import asyncio
 import pytest
 
 from juju.client.connection import Connection
@@ -47,7 +48,7 @@ async def test_monitor_catches_error(event_loop):
 @pytest.mark.asyncio
 async def test_full_status(event_loop):
     async with base.CleanModel() as model:
-        app = await model.deploy(
+        await model.deploy(
             'ubuntu-0',
             application_name='ubuntu',
             series='trusty',
@@ -56,4 +57,27 @@ async def test_full_status(event_loop):
 
         c = client.ClientFacade.from_connection(model.connection)
 
-        status = await c.FullStatus(None)
+        await c.FullStatus(None)
+
+
+@base.bootstrapped
+@pytest.mark.asyncio
+async def test_reconnect(event_loop):
+    async with base.CleanModel() as model:
+        conn = await Connection.connect(
+            model.connection.endpoint,
+            model.connection.uuid,
+            model.connection.username,
+            model.connection.password,
+            model.connection.cacert,
+            model.connection.macaroons,
+            model.connection.loop,
+            model.connection.max_frame_size)
+        try:
+            await asyncio.sleep(0.1)
+            assert conn.is_open
+            await conn.ws.close()
+            assert not conn.is_open
+            await model.block_until(lambda: conn.is_open, timeout=3)
+        finally:
+            await conn.close()