Skip to content

Commit

Permalink
integ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arturo-seijas committed Aug 13, 2024
1 parent 3b8aac5 commit 43b9e06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.bandit]
exclude_dirs = ["/venv/"]
[tool.bandit.assert_used]
skips = ["*/*test.py", "*/test_*.py", "*tests/*.py", "tests/integration/provider_charm"]
skips = ["*/*test.py", "*/test_*.py", "*tests/*.py", "tests/integration/tls_provider_charm"]

# Testing tools configuration
[tool.coverage.run]
Expand All @@ -20,7 +20,7 @@ show_missing = true
max-line-length = 99
max-doc-length = 99
max-complexity = 10
exclude = [".git", "__pycache__", ".tox", "build", "dist", "*.egg_info", "venv", "provider_charm"]
exclude = [".git", "__pycache__", ".tox", "build", "dist", "*.egg_info", "venv", "tls_provider_charm"]
select = ["E", "W", "F", "C", "N", "R", "D", "H"]
# Ignore W503, E501 because using black creates errors with this
# Ignore D107 Missing docstring in __init__
Expand All @@ -39,7 +39,7 @@ disallow_untyped_defs = true
explicit_package_bases = true
ignore_missing_imports = true
namespace_packages = true
exclude = 'tests/integration/provider_charm'
exclude = 'tests/integration/tls_provider_charm'

[[tool.mypy.overrides]]
disallow_untyped_defs = false
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def model_fixture(ops_test: OpsTest) -> Model:

@pytest_asyncio.fixture(scope="module", name="model")
async def tls_certificates_provider_fixture(
ops_test: OpsTest, model: Model
ops_test: OpsTest, model: Model
) -> typing.AsyncGenerator[Application, None]:
"""Deploy the tls_certificates_provider charm."""
provider_charm = await ops_test.build_charm(f"{PROVIDER_CHARM_DIR}/")
Expand Down
21 changes: 6 additions & 15 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

"""Integration tests."""

import asyncio
import logging
from pathlib import Path

import pytest
import yaml
from pytest_operator.plugin import OpsTest
from juju.application import Application
from juju.model import Model

logger = logging.getLogger(__name__)

Expand All @@ -20,20 +20,11 @@


@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test: OpsTest, pytestconfig: pytest.Config):
async def test_build_and_deploy(model: Model, application: Application):
"""Deploy the charm together with related charms.
Assert on the unit status before any relations/configurations take place.
Assert on the unit status.
"""
# Deploy the charm and wait for active/idle status
charm = pytestconfig.getoption("--charm-file")
resources = {"httpbin-image": METADATA["resources"]["httpbin-image"]["upstream-source"]}
assert ops_test.model
await asyncio.gather(
ops_test.model.deploy(
f"./{charm}", resources=resources, application_name=APP_NAME, series="jammy"
),
ops_test.model.wait_for_idle(
apps=[APP_NAME], status="active", raise_on_blocked=True, timeout=1000
),
model.wait_for_idle(
apps=[application.name], status="active", raise_on_blocked=True, timeout=1000
)

0 comments on commit 43b9e06

Please # to comment.