Skip to content

Commit

Permalink
- finished unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcocenza committed Jan 31, 2024
1 parent fb49c1c commit 7e51117
Show file tree
Hide file tree
Showing 5 changed files with 256 additions and 140 deletions.
1 change: 0 additions & 1 deletion cou/steps/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ async def filter_hypervisors_machines(args: CLIargs, analysis_result: Analysis)
return {machine for machine in hypervisors_machines if machine.machine_id in cli_machines}

if cli_hostnames := args.hostnames:
print(cli_hostnames)
return {machine for machine in hypervisors_machines if machine.hostname in cli_hostnames}

if cli_azs := args.availability_zones:
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/apps/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

import pytest

from cou.apps.base import ApplicationUnit
from cou.apps.core import Keystone
from cou.apps.machine import Machine
from cou.exceptions import (
ApplicationError,
HaltUpgradePlanGeneration,
Expand All @@ -32,6 +34,13 @@
from tests.unit.apps.utils import add_steps


def test_repr_ApplicationUnit():
app_unit = ApplicationUnit(
"keystone/0", OpenStackRelease("ussuri"), Machine("0", "juju-cef38-0", "zone-1"), "17.0.1"
)
assert repr(app_unit) == "Unit[keystone/0]-Machine[0]"


def test_application_eq(status, config, model, apps_machines):
"""Name of the app is used as comparison between Applications objects."""
status_keystone_1 = status["keystone_focal_ussuri"]
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from cou.apps.machine import Machine
from cou.apps.subordinate import OpenStackSubordinateApplication
from cou.commands import CLIargs
from cou.steps.analyze import Analysis
from cou.utils.openstack import OpenStackRelease

STANDARD_AZS = ["zone-1", "zone-2", "zone-3"]
Expand Down Expand Up @@ -592,6 +593,16 @@ def model(config, apps_machines):
return model


@pytest.fixture
def analysis_result(model, apps):
"""Generate a simple analysis result to be used on unit-tests."""
return Analysis(
model=model,
apps_control_plane=[apps["keystone_focal_ussuri"]],
apps_data_plane=[apps["nova_focal_ussuri"]],
)


@pytest.fixture
def apps(status, config, model, apps_machines):
keystone_focal_ussuri_status = status["keystone_focal_ussuri"]
Expand Down
Loading

0 comments on commit 7e51117

Please sign in to comment.