this repo has no description

select all items on first run (#2)

authored by

Pavel Zwerschke and committed by
GitHub
21a1618d dc740058

+57 -1
+18
pixi.lock
··· 389 389 - conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.19.2-pyhd8ed1ab_0.conda 390 390 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-9.0.2-pyhcf101f3_0.conda 391 391 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-cov-7.0.0-pyhcf101f3_1.conda 392 + - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-mock-3.15.1-pyhd8ed1ab_0.conda 392 393 - conda: https://conda.anaconda.org/conda-forge/linux-64/python-3.14.3-h32b2ec7_100_cp314.conda 393 394 - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.14.3-h4df99d1_100.conda 394 395 - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.14-8_cp314.conda ··· 440 441 - conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.19.2-pyhd8ed1ab_0.conda 441 442 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-9.0.2-pyhcf101f3_0.conda 442 443 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-cov-7.0.0-pyhcf101f3_1.conda 444 + - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-mock-3.15.1-pyhd8ed1ab_0.conda 443 445 - conda: https://conda.anaconda.org/conda-forge/osx-64/python-3.14.3-h4f44bb5_100_cp314.conda 444 446 - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.14.3-h4df99d1_100.conda 445 447 - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.14-8_cp314.conda ··· 492 494 - conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.19.2-pyhd8ed1ab_0.conda 493 495 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-9.0.2-pyhcf101f3_0.conda 494 496 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-cov-7.0.0-pyhcf101f3_1.conda 497 + - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-mock-3.15.1-pyhd8ed1ab_0.conda 495 498 - conda: https://conda.anaconda.org/conda-forge/osx-arm64/python-3.14.3-h4c637c5_100_cp314.conda 496 499 - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.14.3-h4df99d1_100.conda 497 500 - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.14-8_cp314.conda ··· 542 545 - conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.19.2-pyhd8ed1ab_0.conda 543 546 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-9.0.2-pyhcf101f3_0.conda 544 547 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-cov-7.0.0-pyhcf101f3_1.conda 548 + - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-mock-3.15.1-pyhd8ed1ab_0.conda 545 549 - conda: https://conda.anaconda.org/conda-forge/win-64/python-3.14.3-h4b44e0e_100_cp314.conda 546 550 - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.14.3-h4df99d1_100.conda 547 551 - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.14-8_cp314.conda ··· 845 849 - conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.19.2-pyhd8ed1ab_0.conda 846 850 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-9.0.2-pyhcf101f3_0.conda 847 851 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-cov-7.0.0-pyhcf101f3_1.conda 852 + - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-mock-3.15.1-pyhd8ed1ab_0.conda 848 853 - conda: https://conda.anaconda.org/conda-forge/linux-64/python-3.13.12-hc97d973_100_cp313.conda 849 854 - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.13.12-h4df99d1_100.conda 850 855 - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.13-8_cp313.conda ··· 896 901 - conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.19.2-pyhd8ed1ab_0.conda 897 902 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-9.0.2-pyhcf101f3_0.conda 898 903 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-cov-7.0.0-pyhcf101f3_1.conda 904 + - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-mock-3.15.1-pyhd8ed1ab_0.conda 899 905 - conda: https://conda.anaconda.org/conda-forge/osx-64/python-3.13.12-h894a449_100_cp313.conda 900 906 - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.13.12-h4df99d1_100.conda 901 907 - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.13-8_cp313.conda ··· 947 953 - conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.19.2-pyhd8ed1ab_0.conda 948 954 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-9.0.2-pyhcf101f3_0.conda 949 955 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-cov-7.0.0-pyhcf101f3_1.conda 956 + - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-mock-3.15.1-pyhd8ed1ab_0.conda 950 957 - conda: https://conda.anaconda.org/conda-forge/osx-arm64/python-3.13.12-h20e6be0_100_cp313.conda 951 958 - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.13.12-h4df99d1_100.conda 952 959 - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.13-8_cp313.conda ··· 996 1003 - conda: https://conda.anaconda.org/conda-forge/noarch/pygments-2.19.2-pyhd8ed1ab_0.conda 997 1004 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-9.0.2-pyhcf101f3_0.conda 998 1005 - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-cov-7.0.0-pyhcf101f3_1.conda 1006 + - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-mock-3.15.1-pyhd8ed1ab_0.conda 999 1007 - conda: https://conda.anaconda.org/conda-forge/win-64/python-3.13.12-h09917c8_100_cp313.conda 1000 1008 - conda: https://conda.anaconda.org/conda-forge/noarch/python-gil-3.13.12-h4df99d1_100.conda 1001 1009 - conda: https://conda.anaconda.org/conda-forge/noarch/python_abi-3.13-8_cp313.conda ··· 3032 3040 license_family: MIT 3033 3041 size: 29016 3034 3042 timestamp: 1757612051022 3043 + - conda: https://conda.anaconda.org/conda-forge/noarch/pytest-mock-3.15.1-pyhd8ed1ab_0.conda 3044 + sha256: 2936717381a2740c7bef3d96827c042a3bba3ba1496c59892989296591e3dabb 3045 + md5: 0511afbe860b1a653125d77c719ece53 3046 + depends: 3047 + - pytest >=6.2.5 3048 + - python >=3.10 3049 + license: MIT 3050 + license_family: MIT 3051 + size: 22968 3052 + timestamp: 1758101248317 3035 3053 - conda: https://conda.anaconda.org/conda-forge/linux-64/python-3.13.12-hc97d973_100_cp313.conda 3036 3054 build_number: 100 3037 3055 sha256: 8a08fe5b7cb5a28aa44e2994d18dbf77f443956990753a4ca8173153ffb6eb56
+1
pixi.toml
··· 19 19 pytest = "*" 20 20 pytest-cov = "*" 21 21 ty = "*" 22 + pytest-mock = ">=3.15.1,<4" 22 23 [feature.test.tasks] 23 24 test = "pytest" 24 25 test-coverage = "pytest --cov=pixi_skills --cov-report=xml --cov-report=term-missing"
+1 -1
pixi_skills/selector.py
··· 43 43 questionary.Choice( 44 44 title=f"{skill.name} ({skill.description})", 45 45 value=skill, 46 - checked=skill.name in installed, 46 + checked=(not installed) or (skill.name in installed), 47 47 ) 48 48 for skill in sorted_skills 49 49 ]
+37
tests/test_selector.py
··· 1 + from pathlib import Path 2 + 3 + from pytest_mock import MockerFixture 4 + 1 5 from pixi_skills.selector import select_skills_interactively 6 + from pixi_skills.skill import Scope, Skill 2 7 3 8 4 9 class TestSelectSkillsInteractively: ··· 13 18 def test_none_installed_defaults_to_empty(self) -> None: 14 19 result = select_skills_interactively([], None) 15 20 assert result == [] 21 + 22 + def test_all_checked_when_no_installed(self, mocker: MockerFixture) -> None: 23 + """When installed is empty (first use), all skills should be pre-checked.""" 24 + mock_checkbox = mocker.patch("pixi_skills.selector.questionary.checkbox") 25 + mock_checkbox.return_value.ask.return_value = [] 26 + 27 + skills = [ 28 + Skill(scope=Scope.LOCAL, name="skill-a", description="A", path=Path("/a")), 29 + Skill(scope=Scope.LOCAL, name="skill-b", description="B", path=Path("/b")), 30 + ] 31 + select_skills_interactively(skills, installed=set()) 32 + 33 + choices = mock_checkbox.call_args.kwargs["choices"] 34 + assert all(c.checked for c in choices) 35 + 36 + def test_only_installed_checked_when_some_installed( 37 + self, mocker: MockerFixture 38 + ) -> None: 39 + """When some skills are installed, only those should be pre-checked.""" 40 + mock_checkbox = mocker.patch("pixi_skills.selector.questionary.checkbox") 41 + mock_checkbox.return_value.ask.return_value = [] 42 + 43 + skills = [ 44 + Skill(scope=Scope.LOCAL, name="skill-a", description="A", path=Path("/a")), 45 + Skill(scope=Scope.LOCAL, name="skill-b", description="B", path=Path("/b")), 46 + ] 47 + select_skills_interactively(skills, installed={"skill-a"}) 48 + 49 + choices = mock_checkbox.call_args.kwargs["choices"] 50 + choices_by_checked = {c.value.name: c.checked for c in choices} 51 + assert choices_by_checked["skill-a"] is True 52 + assert choices_by_checked["skill-b"] is False