Files
cowork-local/tests/unit/test_turn_runtime.py
T
f9f6bc01fd
CI / test (push) Canceled after 0s
Feature/delta team/epic r04 (#7)
## Summary

epic r04 - begin refactor

## Change Type

- [x] Cowork feature
- [ ] Bug fix
- [ ] Core AI contribution
- [ ] Test / hardening
- [ ] Performance
- [ ] Documentation

## Related Work

Cowork Task:

Core Repo: http://34.143.229.138/gitea-admin/fsg-ai-core-assets

Core AI Issue:

Core Task:

Related PR:

## Scope

What is intentionally included?

What is intentionally NOT included?

## Validation

- [ ] Unit tests
- [ ] Integration tests
- [ ] Manual verification
- [ ] Regression check

Commands / evidence:

## Security Impact

Permission / credential / network / customer data impact:

## Compatibility

- [ ] No breaking change
- [ ] Breaking change documented

## Reviewer Notes

Anything Cowork reviewers should pay attention to.

---------

Co-authored-by: Anh Tran Nguyen Minh <anhtnm1@fpt.com>
Co-authored-by: Huong Le Thi Thien <huongltt35@fpt.com>
Co-authored-by: Nam Pham Dinh Thanh <nampdt@fpt.com>
Co-authored-by: Vu Dam Tuan <vudt15@fpt.com>
Co-authored-by: Hiep Ha Van <hiephv3@fpt.com>
Co-authored-by: Lam Hoang Van <lamhv7@fpt.com>
Reviewed-on: #7
Co-authored-by: Duy Le Huu <duylh19@fpt.com>
2026-08-31 05:15:13 +00:00

37 lines
1.4 KiB
Python

"""R04-T04 — unit tests for the shared turn-runtime helpers.
``combine_instructions`` is the small rule the UI applied inline: a turn's
standing instructions are several independent blocks (project context, an Admin
agent's persona, a skill's rules, an unattended-run reminder) that must be joined
with one blank line, skipping whatever is absent. Two call sites need it (T04's
widget and T05's task runner), which is exactly when a rule stops being an inline
expression.
"""
from __future__ import annotations
from cowork_local.application.conversations.turn_runtime import combine_instructions
def test_two_blocks_are_joined_by_a_blank_line() -> None:
assert combine_instructions("PROJECT", "AGENT") == "PROJECT\n\nAGENT"
def test_an_absent_block_leaves_no_blank_line_behind() -> None:
assert combine_instructions("", "AGENT") == "AGENT"
assert combine_instructions("PROJECT", "") == "PROJECT"
assert combine_instructions("PROJECT", None) == "PROJECT"
def test_whitespace_only_blocks_do_not_count_as_instructions() -> None:
assert combine_instructions(" \n ", "AGENT") == "AGENT"
def test_nothing_to_say_produces_an_empty_string() -> None:
assert combine_instructions() == ""
assert combine_instructions("", None, " ") == ""
def test_more_than_two_blocks_keep_their_order() -> None:
assert combine_instructions("A", "B", "C") == "A\n\nB\n\nC"