Skip to content

Commit

Permalink
- apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcocenza committed Apr 26, 2024
1 parent 2722dc5 commit a968349
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions tests/mocked_plans/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
import pytest

from cou.utils.juju_utils import Model
from tests.mocked_plans.utils import get_sample_files, get_sample_plan
from tests.mocked_plans.utils import get_sample_files, parse_sample_plan_file


@pytest.fixture(params=get_sample_files(), ids=[path.name for path in get_sample_files()])
def sample_plans(request) -> tuple[Model, str]:
"""Return all sample plans in a directory.
def sample_plan(request) -> tuple[Model, str]:
"""Return a sample plan from the sample_plans directory.
This parametrized fixture return a tuple with a cou.utils.juju_utils.Model object and the
expected plan in string format as the value. The get_applications function of this Model object
returns the applications read from a YAML file, from which the expected plan is also parsed.
"""
return get_sample_plan(request.param)
return parse_sample_plan_file(request.param)
4 changes: 2 additions & 2 deletions tests/mocked_plans/test_sample_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

@pytest.mark.asyncio
@patch("cou.utils.nova_compute.get_instance_count", return_value=0)
async def test_plans_with_empty_hypervisors(_, sample_plans):
async def test_plans_with_empty_hypervisors(_, sample_plan):
"""Testing all the plans on sample_plans folder considering all hypervisors empty."""
model, exp_plan = sample_plans
model, exp_plan = sample_plan
args = CLIargs("plan", auto_approve=True)
analysis_results = await Analysis.create(model)
plan = await generate_plan(analysis_results, args)
Expand Down
4 changes: 2 additions & 2 deletions tests/mocked_plans/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from tests.unit.utils import dedent_plan


def get_sample_plan(source: Path) -> tuple[Model, str]:
def parse_sample_plan_file(source: Path) -> tuple[Model, str]:
"""Help function to get dict of Applications and expected upgrade plan from file.
This function can load applications from yaml format, where each app is string representation
Expand Down Expand Up @@ -80,4 +80,4 @@ def get_sample_plan(source: Path) -> tuple[Model, str]:
def get_sample_files() -> list[Path]:
"""Get all the yaml files on the sample_plans folder."""
directory = Path(__file__).parent / "sample_plans"
return [sample_file for sample_file in directory.glob("*.yaml")]
return (sample_file for sample_file in directory.glob("*.yaml"))

0 comments on commit a968349

Please sign in to comment.