Skip to content

tests: add unit tests for OpenAiImageProvider with mocked client#3050

Merged
Salazareo merged 1 commit into
mainfrom
DS/2990
May 9, 2026
Merged

tests: add unit tests for OpenAiImageProvider with mocked client#3050
Salazareo merged 1 commit into
mainfrom
DS/2990

Conversation

@Salazareo
Copy link
Copy Markdown
Member

Mocks the OpenAI SDK at the module boundary, boots a real PuterServer for the wired MeteringService, and covers the three model families the provider treats differently. Exercises construction, model catalog (dall-e-2 default + verbatim list), test_mode bypass, prompt validation, the credit gate (402 before SDK), DALL-E request shape (allowedRatio snap, hd-only-on-DALL-E-3, per-size metering, url and b64_json output), gpt-image-* token-priced metering (input + output batched line items at the model rates), and the gpt-image-2 size normalizer (pixel-budget snap to multiples of 16, 3:1 ratio clamp, 3840 edge cap).

closes #2990

Mocks the OpenAI SDK at the module boundary, boots a real PuterServer
for the wired MeteringService, and covers the three model families
the provider treats differently. Exercises construction, model catalog
(dall-e-2 default + verbatim list), test_mode bypass, prompt
validation, the credit gate (402 before SDK), DALL-E request shape
(allowedRatio snap, hd-only-on-DALL-E-3, per-size metering, url and
b64_json output), gpt-image-* token-priced metering (input + output
batched line items at the model rates), and the gpt-image-2 size
normalizer (pixel-budget snap to multiples of 16, 3:1 ratio clamp,
3840 edge cap).

closes #2990
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 42.36%
⬆️ +0.03%
7487 / 17674
🔵 Statements 41.42%
⬆️ +0.02%
7892 / 19051
🔵 Functions 45.54%
⬇️ -0.34%
1360 / 2986
🔵 Branches 31.34%
⬇️ -0.01%
4401 / 14040
File CoverageNo changed files found.
Generated in workflow #111 for commit 990c4aa by the Vitest Coverage Report Action

@Salazareo Salazareo merged commit 2543179 into main May 9, 2026
4 checks passed
@Salazareo Salazareo deleted the DS/2990 branch May 10, 2026 21:28
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.

[Tests] Add unit tests for OpenAiImageProvider with mocked client

1 participant