sunbeam-charms/charms/openstack-hypervisor/tests/integration/test_charm.py
Hemanth Nakkina 3c7295f19d Format the code
Change pyproject.toml to reflect similar ot other
sunbeam charms.
Run tox -e fmt for formatting.

Change-Id: I21f40c502a8503edd8d4c345b09fc33d0f67c5dc
2023-10-25 09:54:50 +05:30

63 lines
1.7 KiB
Python

#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Integration test for openstack hypervisor charm."""
import asyncio
import logging
from pathlib import (
Path,
)
import pytest
import yaml
from pytest_operator.plugin import (
OpsTest,
)
logger = logging.getLogger(__name__)
METADATA = yaml.safe_load(Path("./metadata.yaml").read_text())
APP_NAME = METADATA["name"]
@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test: OpsTest):
"""Build the charm-under-test and deploy it together with related charms.
Assert on the unit status before any relations/configurations take place.
"""
# Build and deploy charm from local source folder
charm = await ops_test.build_charm(".")
resources = {
"httpbin-image": METADATA["resources"]["httpbin-image"][
"upstream-source"
]
}
# Deploy the charm and wait for active/idle status
await asyncio.gather(
ops_test.model.deploy(
await charm, resources=resources, application_name=APP_NAME
),
ops_test.model.wait_for_idle(
apps=[APP_NAME],
status="active",
raise_on_blocked=True,
timeout=1000,
),
)