Skip to content

Commit

Permalink
tests: bad filter should raise OscApiException with error code 400 (#121
Browse files Browse the repository at this point in the history
)

closes #116

Signed-off-by: Jérôme Jutteau <[email protected]>
  • Loading branch information
jerome-jutteau authored Nov 22, 2021
1 parent 010a533 commit 7049820
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
OSC_TEST_ACCESS_KEY: ${{ secrets.OSC_TEST_ACCESS_KEY }}
OSC_TEST_SECRET_KEY: ${{ secrets.OSC_TEST_SECRET_KEY }}
OSC_TEST_ENDPOINT_ICU: ${{ secrets.OSC_TEST_ENDPOINT_ICU }}
OSC_TEST_ENDPOINT_API: ${{ secrets.OSC_TEST_ENDPOINT_API }}
OSC_TEST_REGION: ${{ secrets.OSC_TEST_REGION }}
- name: Test python package building
run: make build
Expand All @@ -75,6 +76,7 @@ jobs:
OSC_TEST_ACCESS_KEY: ${{ secrets.OSC_TEST_ACCESS_KEY }}
OSC_TEST_SECRET_KEY: ${{ secrets.OSC_TEST_SECRET_KEY }}
OSC_TEST_ENDPOINT_ICU: ${{ secrets.OSC_TEST_ENDPOINT_ICU }}
OSC_TEST_ENDPOINT_API: ${{ secrets.OSC_TEST_ENDPOINT_API }}
OSC_TEST_REGION: ${{ secrets.OSC_TEST_REGION }}
- name: Test python package building
run: make build
Expand All @@ -101,6 +103,7 @@ jobs:
OSC_TEST_ACCESS_KEY: ${{ secrets.OSC_TEST_ACCESS_KEY }}
OSC_TEST_SECRET_KEY: ${{ secrets.OSC_TEST_SECRET_KEY }}
OSC_TEST_ENDPOINT_ICU: ${{ secrets.OSC_TEST_ENDPOINT_ICU }}
OSC_TEST_ENDPOINT_API: ${{ secrets.OSC_TEST_ENDPOINT_API }}
OSC_TEST_REGION: ${{ secrets.OSC_TEST_REGION }}
- name: Test python package building
run: make build
Expand All @@ -127,6 +130,7 @@ jobs:
OSC_TEST_ACCESS_KEY: ${{ secrets.OSC_TEST_ACCESS_KEY }}
OSC_TEST_SECRET_KEY: ${{ secrets.OSC_TEST_SECRET_KEY }}
OSC_TEST_ENDPOINT_ICU: ${{ secrets.OSC_TEST_ENDPOINT_ICU }}
OSC_TEST_ENDPOINT_API: ${{ secrets.OSC_TEST_ENDPOINT_API }}
OSC_TEST_REGION: ${{ secrets.OSC_TEST_REGION }}
- name: Test python package building
run: make build
Expand All @@ -153,6 +157,7 @@ jobs:
OSC_TEST_ACCESS_KEY: ${{ secrets.OSC_TEST_ACCESS_KEY }}
OSC_TEST_SECRET_KEY: ${{ secrets.OSC_TEST_SECRET_KEY }}
OSC_TEST_ENDPOINT_ICU: ${{ secrets.OSC_TEST_ENDPOINT_ICU }}
OSC_TEST_ENDPOINT_API: ${{ secrets.OSC_TEST_ENDPOINT_API }}
OSC_TEST_REGION: ${{ secrets.OSC_TEST_REGION }}
- name: Test python package building
run: make build
37 changes: 37 additions & 0 deletions osc_sdk/test_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
from dataclasses import dataclass

import pytest

from . import sdk


@dataclass
class Env(object):
access_key: str
secret_key: str
endpoint_api: str
region: str


@pytest.fixture
def env() -> Env:
return Env(
access_key=os.getenv("OSC_TEST_ACCESS_KEY", ""),
secret_key=os.getenv("OSC_TEST_SECRET_KEY", ""),
endpoint_api=os.getenv("OSC_TEST_ENDPOINT_API", ""),
region=os.getenv("OSC_TEST_REGION", ""),
)


# issue #116
def test_bad_filter(env):
oapi = sdk.OSCCall(
access_key=env.access_key,
secret_key=env.secret_key,
endpoint=env.endpoint_api,
region_name=env.region,
)
with pytest.raises(sdk.OscApiException) as e:
oapi.make_request("ReadImages", Filters='"bad_filter"')
assert e.value.status_code == 400

0 comments on commit 7049820

Please sign in to comment.