Skip to content

test: add initial test infrastructure with 21 unit tests for utility functions#105

Open
ayazhankadessova wants to merge 1 commit intosugarlabs:mainfrom
ayazhankadessova:feat/add-test-infrastructure
Open

test: add initial test infrastructure with 21 unit tests for utility functions#105
ayazhankadessova wants to merge 1 commit intosugarlabs:mainfrom
ayazhankadessova:feat/add-test-infrastructure

Conversation

@ayazhankadessova
Copy link
Copy Markdown

Summary

Sugar-AI currently has no test infrastructure. This PR adds the first test suite covering pure utility functions that do not require model loading or GPU access.

What's Added

  • tests/__init__.py — makes tests a Python package
  • tests/test_utils.py — 21 tests across 4 function groups:
Function Tests What's covered
extract_answer_from_output 10 None/empty inputs, Answer/Child-friendly markers, precedence, fallback
format_docs 3 Single doc, multiple docs joined, empty list
combine_messages 2 String passthrough, non-string conversion
RAGAgent._extract_after_prompt 6 Prompt removal, EOS token trimming, double-newline truncation with length threshold

Why These Functions

These are pure utility functions with no side effects — they don't need a model loaded, GPU access, or network calls. This makes the tests fast (~4 seconds) and runnable on any contributor's machine.

Running

pip install pytest
python -m pytest tests/ -v

All 21 tests pass:

tests/test_utils.py::TestExtractAnswerFromOutput::test_none_input_returns_empty PASSED
tests/test_utils.py::TestExtractAnswerFromOutput::test_empty_list_returns_empty PASSED
...
======================== 21 passed, 2 warnings in 3.81s ========================

AI Disclosure

This PR was developed with AI assistance (Claude Code). All tests were manually verified against the actual function behavior before submission.

Sugar-AI currently has no tests. This adds the first test suite
covering pure utility functions that do not require model loading
or GPU access:

- extract_answer_from_output: 10 tests (edge cases, markers, fallback)
- format_docs: 3 tests (single, multiple, empty)
- combine_messages: 2 tests (string, non-string)
- _extract_after_prompt: 6 tests (prompt removal, EOS trimming,
  double-newline truncation with length threshold)

All 21 tests pass. Run with: python -m pytest tests/ -v
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.

1 participant