Skip to content

Commit

Permalink
Linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
IbraAoad committed Nov 22, 2023
1 parent ea54432 commit e44e0d0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
9 changes: 5 additions & 4 deletions charm/tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# See LICENSE file for licensing details.

import logging
from subprocess import PIPE, check_output

from pytest_operator.plugin import OpsTest
from subprocess import check_output, PIPE

logger = logging.getLogger(__name__)

Expand All @@ -14,11 +14,12 @@ async def get_unit_address(ops_test: OpsTest, app_name: str, unit_num: int) -> s
return status["applications"][app_name]["units"][f"{app_name}/{unit_num}"]["address"]


async def run_juju_ssh_command(model_full_name: str, container_name: str, unit_name: str, command: str):
result = check_output(
async def run_juju_ssh_command(
model_full_name: str, container_name: str, unit_name: str, command: str
):
return check_output(
f"JUJU_MODEL={model_full_name} juju ssh --container {container_name} {unit_name} '{command}' ",
stderr=PIPE,
shell=True,
universal_newlines=True,
)
return result
19 changes: 10 additions & 9 deletions charm/tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


import asyncio
import json
import logging
from pathlib import Path

Expand All @@ -12,7 +13,6 @@
import yaml
from helpers import get_unit_address, run_juju_ssh_command
from pytest_operator.plugin import OpsTest
import json

logger = logging.getLogger(__name__)

Expand All @@ -32,8 +32,7 @@ async def test_build_and_deploy(ops_test: OpsTest):
# Then it should eventually go idle/active

charm = await ops_test.build_charm(".")
resources = {
"catalogue-image": METADATA["resources"]["catalogue-image"]["upstream-source"]}
resources = {"catalogue-image": METADATA["resources"]["catalogue-image"]["upstream-source"]}
await ops_test.model.deploy(charm, resources=resources, application_name=APP_NAME)

# issuing dummy update_status just to trigger an event
Expand Down Expand Up @@ -81,10 +80,12 @@ async def test_app_integration(ops_test: OpsTest):
apps=[APP_NAME, alert_app_name], status="active", raise_on_blocked=True, timeout=1000
)
# retrieve the content of /web/config.json which holds application data in the catalogue
new_config = await run_juju_ssh_command(model_full_name=ops_test.model_full_name,
container_name="catalogue",
unit_name= f"{APP_NAME}/0",
command="cat /web/config.json",)
new_config = await run_juju_ssh_command(
model_full_name=ops_test.model_full_name,
container_name="catalogue",
unit_name=f"{APP_NAME}/0",
command="cat /web/config.json",
)
config_dict = json.loads(new_config)
first_app_name = config_dict['apps'][0]['name']
assert first_app_name == 'Alertmanager'
first_app_name = config_dict["apps"][0]["name"]
assert first_app_name == "Alertmanager"
14 changes: 7 additions & 7 deletions charm/tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@

import json
import unittest
from unittest.mock import patch
from unittest.mock import Mock, patch
from urllib.parse import urlparse

from charm import CatalogueCharm
from charms.catalogue_k8s.v1.catalogue import DEFAULT_RELATION_NAME
from ops.model import ActiveStatus
from ops.testing import Harness
from unittest.mock import patch, Mock
from urllib.parse import urlparse

CONTAINER_NAME = "catalogue"

Expand Down Expand Up @@ -77,8 +76,7 @@ def test_reconfigure_applications(self):

def test_server_cert(self):
# Test with TLS
self.harness.charm.server_cert = Mock(
ca="mock_ca", cert="mock_cert", key="mock_key")
self.harness.charm.server_cert = Mock(ca="mock_ca", cert="mock_cert", key="mock_key")
self.harness.charm._on_server_cert_changed(None)

internal_url = urlparse(self.harness.charm._internal_url)
Expand Down Expand Up @@ -108,8 +106,10 @@ def items(self):
# Test with ingress ready
self.harness.charm._info = MockInfo()
self.harness.charm._on_ingress_ready(Mock(url="https://testingress.com"))

mock_logger.info.assert_called_with("This app's ingress URL: %s", 'https://testingress.com')

mock_logger.info.assert_called_with(
"This app's ingress URL: %s", "https://testingress.com"
)
mock_configure.assert_called_with({"name": "dummyname"}, push_certs=True)

Check failure on line 113 in charm/tests/unit/test_charm.py

View workflow job for this annotation

GitHub Actions / Inclusive naming check

[Inclusive naming check] charm/tests/unit/test_charm.py#L113

[warning] `dummy` may be insensitive, use `placeholder`, `sample` instead
Raw output
charm/tests/unit/test_charm.py:113:52: [warning] `dummy` may be insensitive, use `placeholder`, `sample` instead

mock_logger.reset_mock()
Expand Down

0 comments on commit e44e0d0

Please sign in to comment.