-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b02cf85
commit 108b1ce
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import ops | ||
import pytest | ||
|
||
import scenario | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def mycharm(): | ||
class MyCharm(ops.CharmBase): | ||
def __init__(self, framework: ops.Framework): | ||
super().__init__(framework) | ||
for evt in self.on.events().values(): | ||
self.framework.observe(evt, self._on_event) | ||
|
||
def _on_event(self, event): | ||
pass | ||
|
||
return MyCharm | ||
|
||
|
||
def test_get_cloud_spec(mycharm): | ||
cloud_spec = ops.model.CloudSpec.from_dict( | ||
{ | ||
"name": "localhost", | ||
"type": "lxd", | ||
"endpoint": "https://127.0.0.1:8443", | ||
"credential": { | ||
"auth-type": "certificate", | ||
"attrs": { | ||
"client-cert": "foo", | ||
"client-key": "bar", | ||
"server-cert": "baz", | ||
}, | ||
}, | ||
} | ||
) | ||
|
||
ctx = scenario.Context(mycharm, meta={"name": "foo"}) | ||
with ctx.manager("start", scenario.State(cloud_spec=cloud_spec)) as mgr: | ||
assert mgr.charm.model.get_cloud_spec() == cloud_spec |