Loading pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_main.py +28 −32 Original line number Diff line number Diff line Loading @@ -136,34 +136,34 @@ def test_reexec(mock_build: Mock, mock_execve: Mock, monkeypatch: MonkeyPatch) - mock_build.return_value = Path("/path") nr.reexec(argv, args, {"build": True}, {"flake": True}) assert mock_build.call_args_list == [ mock_build.assert_has_calls( [ call( "config.system.build.nixos-rebuild", nr.models.BuildAttr(ANY, ANY), {"build": True, "no_out_link": True}, ) ] ) # do not exec if there is no new version assert mock_execve.call_args_list == [] mock_execve.assert_not_called() mock_build.return_value = Path("/path/new") nr.reexec(argv, args, {}, {}) # exec in the new version successfully assert mock_execve.call_args_list == [ call( mock_execve.assert_called_once_with( Path("/path/new/bin/nixos-rebuild-ng"), ["/path/bin/nixos-rebuild-ng", "switch", "--no-flake"], {"_NIXOS_REBUILD_REEXEC": "1"}, ) ] mock_execve.reset_mock() mock_execve.side_effect = [OSError("BOOM"), None] nr.reexec(argv, args, {}, {}) # exec in the previous version if the new version fails assert mock_execve.call_args == call( mock_execve.assert_any_call( Path("/path/bin/nixos-rebuild-ng"), ["/path/bin/nixos-rebuild-ng", "switch", "--no-flake"], {"_NIXOS_REBUILD_REEXEC": "1"}, Loading @@ -182,34 +182,30 @@ def test_reexec_flake( mock_build.return_value = Path("/path") nr.reexec(argv, args, {"build": True}, {"flake": True}) assert mock_build.call_args_list == [ call( mock_build.assert_called_once_with( "config.system.build.nixos-rebuild", nr.models.Flake(ANY, ANY), {"flake": True, "no_link": True}, ) ] # do not exec if there is no new version assert mock_execve.call_args_list == [] mock_execve.assert_not_called() mock_build.return_value = Path("/path/new") nr.reexec(argv, args, {}, {}) # exec in the new version successfully assert mock_execve.call_args_list == [ call( mock_execve.assert_called_once_with( Path("/path/new/bin/nixos-rebuild-ng"), ["/path/bin/nixos-rebuild-ng", "switch", "--flake"], {"_NIXOS_REBUILD_REEXEC": "1"}, ) ] mock_execve.reset_mock() mock_execve.side_effect = [OSError("BOOM"), None] nr.reexec(argv, args, {}, {}) # exec in the previous version if the new version fails assert mock_execve.call_args == call( mock_execve.assert_any_call( Path("/path/bin/nixos-rebuild-ng"), ["/path/bin/nixos-rebuild-ng", "switch", "--flake"], {"_NIXOS_REBUILD_REEXEC": "1"}, Loading pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_models.py +1 −0 Original line number Diff line number Diff line Loading @@ -167,6 +167,7 @@ def test_profile_from_arg(mock_mkdir: Mock) -> None: "system", Path("/nix/var/nix/profiles/system"), ) mock_mkdir.assert_not_called() assert m.Profile.from_arg("something") == m.Profile( "something", Loading pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py +1 −1 Original line number Diff line number Diff line Loading @@ -762,7 +762,7 @@ def test_switch_to_configuration(mock_run: Mock, monkeypatch: MonkeyPatch) -> No def test_upgrade_channels(mock_is_dir: Mock, mock_glob: Mock) -> None: with patch(get_qualified_name(n.run_wrapper, n), autospec=True) as mock_run: n.upgrade_channels(False) mock_run.assert_called_with(["nix-channel", "--update", "nixos"], check=False) mock_run.assert_called_once_with(["nix-channel", "--update", "nixos"], check=False) with patch(get_qualified_name(n.run_wrapper, n), autospec=True) as mock_run: n.upgrade_channels(True) Loading Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_main.py +28 −32 Original line number Diff line number Diff line Loading @@ -136,34 +136,34 @@ def test_reexec(mock_build: Mock, mock_execve: Mock, monkeypatch: MonkeyPatch) - mock_build.return_value = Path("/path") nr.reexec(argv, args, {"build": True}, {"flake": True}) assert mock_build.call_args_list == [ mock_build.assert_has_calls( [ call( "config.system.build.nixos-rebuild", nr.models.BuildAttr(ANY, ANY), {"build": True, "no_out_link": True}, ) ] ) # do not exec if there is no new version assert mock_execve.call_args_list == [] mock_execve.assert_not_called() mock_build.return_value = Path("/path/new") nr.reexec(argv, args, {}, {}) # exec in the new version successfully assert mock_execve.call_args_list == [ call( mock_execve.assert_called_once_with( Path("/path/new/bin/nixos-rebuild-ng"), ["/path/bin/nixos-rebuild-ng", "switch", "--no-flake"], {"_NIXOS_REBUILD_REEXEC": "1"}, ) ] mock_execve.reset_mock() mock_execve.side_effect = [OSError("BOOM"), None] nr.reexec(argv, args, {}, {}) # exec in the previous version if the new version fails assert mock_execve.call_args == call( mock_execve.assert_any_call( Path("/path/bin/nixos-rebuild-ng"), ["/path/bin/nixos-rebuild-ng", "switch", "--no-flake"], {"_NIXOS_REBUILD_REEXEC": "1"}, Loading @@ -182,34 +182,30 @@ def test_reexec_flake( mock_build.return_value = Path("/path") nr.reexec(argv, args, {"build": True}, {"flake": True}) assert mock_build.call_args_list == [ call( mock_build.assert_called_once_with( "config.system.build.nixos-rebuild", nr.models.Flake(ANY, ANY), {"flake": True, "no_link": True}, ) ] # do not exec if there is no new version assert mock_execve.call_args_list == [] mock_execve.assert_not_called() mock_build.return_value = Path("/path/new") nr.reexec(argv, args, {}, {}) # exec in the new version successfully assert mock_execve.call_args_list == [ call( mock_execve.assert_called_once_with( Path("/path/new/bin/nixos-rebuild-ng"), ["/path/bin/nixos-rebuild-ng", "switch", "--flake"], {"_NIXOS_REBUILD_REEXEC": "1"}, ) ] mock_execve.reset_mock() mock_execve.side_effect = [OSError("BOOM"), None] nr.reexec(argv, args, {}, {}) # exec in the previous version if the new version fails assert mock_execve.call_args == call( mock_execve.assert_any_call( Path("/path/bin/nixos-rebuild-ng"), ["/path/bin/nixos-rebuild-ng", "switch", "--flake"], {"_NIXOS_REBUILD_REEXEC": "1"}, Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_models.py +1 −0 Original line number Diff line number Diff line Loading @@ -167,6 +167,7 @@ def test_profile_from_arg(mock_mkdir: Mock) -> None: "system", Path("/nix/var/nix/profiles/system"), ) mock_mkdir.assert_not_called() assert m.Profile.from_arg("something") == m.Profile( "something", Loading
pkgs/by-name/ni/nixos-rebuild-ng/src/tests/test_nix.py +1 −1 Original line number Diff line number Diff line Loading @@ -762,7 +762,7 @@ def test_switch_to_configuration(mock_run: Mock, monkeypatch: MonkeyPatch) -> No def test_upgrade_channels(mock_is_dir: Mock, mock_glob: Mock) -> None: with patch(get_qualified_name(n.run_wrapper, n), autospec=True) as mock_run: n.upgrade_channels(False) mock_run.assert_called_with(["nix-channel", "--update", "nixos"], check=False) mock_run.assert_called_once_with(["nix-channel", "--update", "nixos"], check=False) with patch(get_qualified_name(n.run_wrapper, n), autospec=True) as mock_run: n.upgrade_channels(True) Loading