Skip to content

Commit 119a980

Browse files
committed
✅ test: add test cases for RFC 9457 implementation
1 parent 04f9d69 commit 119a980

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

.github/workflows/Pyinstaller-windows.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ jobs:
2424
python -m pip install pyinstaller
2525
python -m pip install .
2626
pyinstaller --distpath ./pkg --clean --name osc-cli osc_sdk/sdk.py
27+
Compress-Archive -Path pkg/osc-cli -DestinationPath osc-cli-x86_64.zip
2728
2829
- name: smoke test
2930
run: |
3031
./pkg/osc-cli/osc-cli.exe api ReadRegions | grep api.eu-west-2.outscale.com
32+
33+
- name: Upload artifact
34+
if: github.event_name == 'push'
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: osc-cli-win64
38+
path: osc-cli-x86_64.zip

osc_sdk/test_problems.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import json
2+
from typing import List
3+
4+
import pytest
5+
6+
from .sdk import Problem, ProblemDecoder
7+
8+
RAW_JSONS: List[str] = [
9+
r'{"type":"/errors/unsupported_media_type","status":415,"title":"Unsupported Media Type","detail":"Expected request with `Content-Type: application/json`"}',
10+
r'{"type":"/errors/invalid_parameter","status":400,"title":"Bad Request","detail":"Origin: unknown variant `BAD_VALUE`, expected `OSC_KMS` or `EXTERNAL`"}',
11+
r'{"type":"/errors/invalid_parameter","status":400,"title":"Bad Request","detail":"missing field `KeyId`"}',
12+
"""{"type":"/errors/invalid_parameter","status":400,"title":"Bad Request","detail":"KeyId: 'mck-toto' is not a key ID, an alias name, a key ORN or an alias ORN"}""",
13+
r'{"type":"/errors/invalid_parameter","status":404,"title":"Not Found","detail":"Key not found: mck-6480ba0cd94845deb4967f18c6b32cb1"}',
14+
]
15+
16+
17+
@pytest.mark.parametrize("raw_json", RAW_JSONS)
18+
def test_decode_raw_json_errors(raw_json: str):
19+
"""Test that ProblemDecoder can correctly decode raw JSON error strings."""
20+
decoded = json.loads(raw_json, cls=ProblemDecoder)
21+
assert isinstance(decoded, Problem)

0 commit comments

Comments
 (0)