11 async def test_juju_api_error(event_loop
):
13 Verify that we raise a JujuAPIError for responses with an error in
14 a top level key (for completely invalid requests).
17 from juju
.errors
import JujuAPIError
19 async with base
.CleanModel() as model
:
20 with pytest
.raises(JujuAPIError
):
21 await model
.add_machine(constraints
={'mem': 'foo'})
26 async def test_juju_error_in_results_list(event_loop
):
28 Replicate the code that caused
29 https://github.com/juju/python-libjuju/issues/67, and verify that
30 we get a JujuError instead of passing silently by the failure.
32 (We don't raise a JujuAPIError, because the request isn't
33 completely invalid -- it's just passing a tag that doesn't exist.)
35 This also verifies that we will raise a JujuError any time there
36 is an error in one of a list of results.
39 from juju
.errors
import JujuError
40 from juju
.client
import client
42 async with base
.CleanModel() as model
:
43 ann_facade
= client
.AnnotationsFacade
.from_connection(model
.connection())
45 ann
= client
.EntityAnnotations(
47 annotations
={'gui-x': '1', 'gui-y': '1'},
49 with pytest
.raises(JujuError
):
50 return await ann_facade
.Set([ann
])
55 async def test_juju_error_in_result(event_loop
):
57 Verify that we raise a JujuError when appropraite when we are
58 looking at a single result coming back.
61 from juju
.errors
import JujuError
62 from juju
.client
import client
64 async with base
.CleanModel() as model
:
65 app_facade
= client
.ApplicationFacade
.from_connection(model
.connection())
67 with pytest
.raises(JujuError
):
68 return await app_facade
.GetCharmURL('foo')