Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test print_profiles function
  • Loading branch information
cadenmyers13 committed Nov 18, 2025
commit d78efd5b2b7873952165bc6b295d704930a4e35d
47 changes: 47 additions & 0 deletions tests/test_profilesmanager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import pytest
import yaml

from diffpy.cmi.profilesmanager import ProfilesManager

install_params = [
( # input: profiles to install
# expected: print_profile output showing profileA
# installed but not profileB
("profileA",),
"""Installed Profiles:
-------------------
profileA

Available Profiles:
-------------------
profileB
""",
),
]


@pytest.mark.parametrize("profiles_to_install,expected", install_params)
def test_print_profiles(
profiles_to_install, expected, example_cases, capsys, mocker
):
case5dir = example_cases / "case5"
req_dir = case5dir / "requirements" / "profiles"

installed_reqs = []
for profile in profiles_to_install:
req_file = req_dir / f"{profile}.yml"
content = yaml.safe_load(req_file.read_text())
for pack in content.get("packs", []):
installed_reqs.append(pack)

def fake_check_profile(identifier):
return identifier == "profileA"

mocker.patch.object(
ProfilesManager, "check_profile", side_effect=fake_check_profile
)
pfm = ProfilesManager(root_path=case5dir)
pfm.print_profiles()
captured = capsys.readouterr()
actual = captured.out
assert actual.strip() == expected.strip()