Skip to content

Commit

Permalink
Add complex bundles on mocked_plans (canonical#391)
Browse files Browse the repository at this point in the history
- order apps by charm and application name to have always the same
sequence
  • Loading branch information
gabrielcocenza authored Apr 29, 2024
1 parent 398678d commit 7398e8f
Show file tree
Hide file tree
Showing 6 changed files with 14,450 additions and 23 deletions.
4 changes: 3 additions & 1 deletion cou/steps/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ async def _populate(cls, model: juju_utils.Model) -> list[OpenStackApplication]:
key=lambda app: UPGRADE_ORDER.index(app.charm),
)
# order by charm name to have a predictable upgrade sequence of other o7k charms.
other_o7k_apps_sorted_by_name = sorted(other_o7k_apps, key=lambda app: app.charm)
other_o7k_apps_sorted_by_name = sorted(
other_o7k_apps, key=lambda app: (app.charm, app.name)
)
return sorted_apps_to_upgrade_in_order + other_o7k_apps_sorted_by_name

def __str__(self) -> str:
Expand Down
24 changes: 8 additions & 16 deletions tests/mocked_plans/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from pathlib import Path

import pytest

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


@pytest.fixture(scope="session")
def sample_plans() -> dict[str, tuple[Model, str]]:
"""Fixture that returns all sample plans in a directory.
@pytest.fixture(params=get_sample_files(), ids=[path.name for path in get_sample_files()])
def sample_plan(request) -> tuple[Model, str]:
"""Return a sample plan from the sample_plans directory.
This fixture returns a dictionary with the filename as the key and
a tuple consisting of 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.
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.
"""
directory = Path(__file__).parent / "sample_plans"

yield {
sample_file.name: get_sample_plan(sample_file) for sample_file in directory.glob("*.yaml")
}
return parse_sample_plan_file(request.param)
Loading

0 comments on commit 7398e8f

Please sign in to comment.