Commit 006485c
authored
* test(backends): fix vision Ollama tests failing in CI with 400 model does not support vision
Structural payload tests (test_image_block_in_instruction, test_image_block_in_chat)
were failing in CI because the m_session fixture called start_session() with no
model_id, resolving to IBM_GRANITE_4_1_3B (granite4.1:3b) — a text-only model.
Attaching images caused Ollama to reject the request with 400, preventing
post_processing from running and the structural assertions from ever executing.
Fixes are:
1. Add test/backends/conftest.py with a shared mock_ollama_backend fixture that
constructs an OllamaModelBackend entirely offline (patches _check_ollama_server,
_pull_ollama_model, ollama.Client, ollama.AsyncClient). No live server required.
2. Rewrite test_vision_ollama.py into three tiers:
- Tier 1 (construction): pure ImageBlock unit tests, no model or server.
- Tier 2 (structural payload): mocked offline tests that verify images are
embedded correctly in the Ollama conversation payload. The _async_client
property is mocked via PropertyMock at the class level so the mock is
returned regardless of which event loop _run_async_in_thread creates in
its background thread. Runs in CI unconditionally.
- Tier 3 (dormant e2e): skipped until granite-vision-4.1 lands on Ollama;
tracked in #1187.
3. Refactor test_ollama_unit.py to use the shared mock_ollama_backend fixture,
removing the duplicated _make_backend() helper.
Closes #1185.
Assisted-by: Claude Code
Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
* test(backends): address code review findings for vision Ollama tests
Remove dead code after unconditional pytest.skip() in vision_session —
the availability check is now the sole gate, which auto-activates once
granite-vision-4.1 lands on Ollama. Update conftest.py docstring to show
the correct PropertyMock class-level patching pattern (instance assignment
does not override the event-loop-keyed _async_client property). Compute
ImageBlock.from_pil_image() once in test_image_block_in_chat instead of
three times.
Assisted-by: Claude Code
Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
---------
Signed-off-by: Nigel Jones <jonesn@uk.ibm.com>
1 parent 6b2132b commit 006485c
3 files changed
Lines changed: 219 additions & 106 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | 18 | | |
34 | | - | |
| 19 | + | |
35 | 20 | | |
36 | | - | |
| 21 | + | |
37 | 22 | | |
38 | 23 | | |
39 | 24 | | |
| |||
73 | 58 | | |
74 | 59 | | |
75 | 60 | | |
76 | | - | |
| 61 | + | |
77 | 62 | | |
78 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
79 | 66 | | |
80 | 67 | | |
81 | 68 | | |
| |||
189 | 176 | | |
190 | 177 | | |
191 | 178 | | |
192 | | - | |
| 179 | + | |
193 | 180 | | |
194 | | - | |
| 181 | + | |
195 | 182 | | |
196 | 183 | | |
197 | 184 | | |
| |||
0 commit comments