Feature/api version support (#109)
[osm/N2VC.git] / tests / integration / test_connection.py
1 import pytest
2
3 from juju.client.connection import Connection
4 from juju.client import client
5 from .. import base
6
7
8 @base.bootstrapped
9 @pytest.mark.asyncio
10 async def test_connect_current(event_loop):
11 async with base.CleanModel():
12 conn = await Connection.connect_current()
13
14 assert isinstance(conn, Connection)
15 await conn.close()
16
17
18 @base.bootstrapped
19 @pytest.mark.asyncio
20 async def test_monitor(event_loop):
21
22 async with base.CleanModel():
23 conn = await Connection.connect_current()
24
25 assert conn.monitor.status == 'connected'
26 await conn.close()
27
28 assert conn.monitor.status == 'disconnected'
29
30
31 @base.bootstrapped
32 @pytest.mark.asyncio
33 async def test_monitor_catches_error(event_loop):
34
35 async with base.CleanModel():
36 conn = await Connection.connect_current()
37
38 assert conn.monitor.status == 'connected'
39 await conn.ws.close()
40
41 assert conn.monitor.status == 'error'
42
43 await conn.close()
44
45
46 @base.bootstrapped
47 @pytest.mark.asyncio
48 async def test_full_status(event_loop):
49 async with base.CleanModel() as model:
50 app = await model.deploy(
51 'ubuntu-0',
52 application_name='ubuntu',
53 series='trusty',
54 channel='stable',
55 )
56
57 c = client.ClientFacade.from_connection(model.connection)
58
59 status = await c.FullStatus(None)