llm icon indicating copy to clipboard operation
llm copied to clipboard

Tests that exercise executing a template with attachments and attachment types

Open simonw opened this issue 1 year ago • 3 comments

I didn't add these when working on:

  • #826

simonw avatar Apr 07 '25 14:04 simonw

I did add this test for --save with --attachment and --attachment-type:

https://github.com/simonw/llm/blob/388a4ea9a2f7ff2787ab40471470419433857391/tests/test_templates.py#L130-L138

What's missing is the test that demonstrates that running llm -t X for a template with these definitely works - and that you can combine that template with further attachments, as manually tested here: https://github.com/simonw/llm/issues/826#issuecomment-2783475340

simonw avatar Apr 07 '25 14:04 simonw

This test should go here - but needs a bit of attention to mock things correctly: https://github.com/simonw/llm/blob/631835ef71f4ebba51cf451a75a879d810d35858/tests/test_templates.py#L275-L297

simonw avatar Apr 07 '25 14:04 simonw

I would like to take this on. The current tests/test_templates.py covers saving attachment declarations, but the ordinary llm -t execution tests still do not exercise templates containing attachments.

I will add tests beside the existing template execution tests for both attachments and attachment_types, including template-only execution and combination with additional CLI -a / --at attachments. The tests will check the actual mocked OpenAI request payload and attachment ordering, with local files and mocked URL metadata so they do not require a real API key or network requests. This should be a tests-only change.

AI assistance is being used for the implementation and validation.

bianyh avatar Oct 11 '26 15:10 bianyh