Skip to content

test(cli): add direct unit tests for ollama lifecycle helpers#1029

Merged
muddlebee merged 2 commits intoTracer-Cloud:mainfrom
Davidson3556:test/ollama-lifecycle-helpers
Apr 28, 2026
Merged

test(cli): add direct unit tests for ollama lifecycle helpers#1029
muddlebee merged 2 commits intoTracer-Cloud:mainfrom
Davidson3556:test/ollama-lifecycle-helpers

Conversation

@Davidson3556
Copy link
Copy Markdown
Contributor

@Davidson3556 Davidson3556 commented Apr 28, 2026

Fixes #906

Describe the changes you have made in this PR

Added tests/cli/test_local_llm_ollama_lifecycle.py with 14 direct unit tests covering the lifecycle helpers in app/cli/local_llm/ollama.py:

  • is_installed() — ollama found on PATH / not found
  • start_server() — correct Popen args and DEVNULL stdio wiring
  • wait_for_server() — succeeds on first try, succeeds after retries, times out correctly
  • install() macOS — brew present + user confirms, user declines, no brew (prints manual link), subprocess failure
  • install() Linux — user confirms, user declines, subprocess failure
  • install() Windows — returns False (unsupported)

No real package managers or ollama processes are invoked. All external calls (shutil.which, subprocess.Popen, subprocess.run, time.sleep, httpx, questionary) are monkeypatched.

Demo/Screenshot

Screenshot 2026-04-28 at 02 49 16

All 14 tests pass:

python3 -m pytest tests/cli/test_local_llm_ollama_lifecycle.py -v

PASSED test_is_installed_returns_true_when_ollama_on_path
PASSED test_is_installed_returns_false_when_ollama_not_on_path
PASSED test_start_server_opens_popen_with_ollama_serve
PASSED test_wait_for_server_returns_true_on_first_attempt
PASSED test_wait_for_server_returns_true_after_retries
PASSED test_wait_for_server_returns_false_on_timeout
PASSED test_install_macos_brew_present_user_confirms_succeeds
PASSED test_install_macos_brew_present_user_declines_returns_false
PASSED test_install_macos_brew_absent_returns_false_and_prints_link
PASSED test_install_macos_brew_present_subprocess_fails_returns_false
PASSED test_install_linux_user_confirms_succeeds
PASSED test_install_linux_user_declines_returns_false
PASSED test_install_linux_subprocess_fails_returns_false
PASSED test_install_windows_returns_false
14 passed in 0.13s

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

Adds 14 focused unit tests for the Ollama lifecycle helpers in app/cli/local_llm/ollama.py, covering all four public functions and all platform branches. All patches target the correct symbols and all assertions accurately reflect the implementation's control flow.

Confidence Score: 5/5

Safe to merge — test-only change with no production code modifications and correct assertions throughout

All 14 tests are logically correct against the implementation. No P0/P1 issues found. Remaining findings are minor style suggestions (inline imports, type annotation precision) that do not affect test correctness or CI.

No files require special attention

Important Files Changed

Filename Overview
tests/cli/test_local_llm_ollama_lifecycle.py 14 new unit tests covering is_installed, start_server, wait_for_server, and install (macOS/Linux/Windows); all assertions are logically correct against the implementation; minor style issues (inline imports, annotation precision)

Reviews (1): Last reviewed commit: "test(cli): add direct unit tests for oll..." | Re-trigger Greptile

Comment thread tests/cli/test_local_llm_ollama_lifecycle.py Outdated
Comment thread tests/cli/test_local_llm_ollama_lifecycle.py Outdated
@Davidson3556
Copy link
Copy Markdown
Contributor Author

@muddlebee @rrajan94 @VaibhavUpreti kindly review this as well

@muddlebee muddlebee merged commit c589348 into Tracer-Cloud:main Apr 28, 2026
7 checks passed
@muddlebee
Copy link
Copy Markdown
Collaborator

@Davidson3556 great work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add direct unit tests for install/start/wait helpers in app/cli/local_llm/ollama.py

2 participants