Skip to content

Commit

Permalink
fix: Fixed comments in PR #2.
Browse files Browse the repository at this point in the history
  • Loading branch information
bencekov committed Mar 22, 2023
1 parent 7e421e3 commit d600201
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def harness(mocked_kubernetes_service_patcher):
"""Initialize harness with Charm."""
harness = ops.testing.Harness(IdentityPlatformLoginUiOperatorCharm)
harness.set_model_name("testing")
harness.set_leader(True)
harness.begin()
return harness

Expand Down
15 changes: 9 additions & 6 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
TEST_KRATOS_URL = "http://kratos:port"


def setup_ingress_relation(harness):
def setup_ingress_relation(harness) -> int:
"""Set up ingress relation."""
harness.set_leader(True)
relation_id = harness.add_relation("ingress", "traefik")
harness.add_relation_unit(relation_id, "traefik/0")
url = f"http://ingress:80/{harness.model.name}-identity-platform-login-ui"
Expand All @@ -27,7 +28,7 @@ def setup_ingress_relation(harness):
return relation_id


def test_not_leader(harness):
def test_not_leader(harness) -> None:
"""Test with unit not being leader."""
harness.set_leader(False)

Expand All @@ -41,16 +42,18 @@ def test_not_leader(harness):
) in harness._get_backend_calls()


def test_install_can_connect(harness):
def test_install_can_connect(harness) -> None:
"""Test installation with connection."""
harness.set_leader(True)
harness.set_can_connect(CONTAINER_NAME, True)
harness.charm.on.login_ui_pebble_ready.emit(CONTAINER_NAME)

assert harness.charm.unit.status == ActiveStatus()


def test_install_can_not_connect(harness):
def test_install_can_not_connect(harness) -> None:
"""Test installation with connection."""
harness.set_leader(True)
harness.set_can_connect(CONTAINER_NAME, False)
harness.charm.on.login_ui_pebble_ready.emit(CONTAINER_NAME)

Expand All @@ -59,11 +62,11 @@ def test_install_can_not_connect(harness):

def test_layer_updated(harness) -> None:
"""Test Pebble Layers after updates."""
harness.set_leader(True)
harness.set_can_connect(CONTAINER_NAME, True)
harness.charm.on.login_ui_pebble_ready.emit(CONTAINER_NAME)

harness.update_config({"hydra_url": TEST_HYDRA_URL})
harness.update_config({"kratos_url": TEST_KRATOS_URL})
harness.update_config({"hydra_url": TEST_HYDRA_URL, "kratos_url": TEST_KRATOS_URL})

expected_layer = {
"summary": "login_ui layer",
Expand Down

0 comments on commit d600201

Please sign in to comment.