-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #139 Support for pyOrthanc in orthanc-server-extensions * introduce ClientType for (Async)Orthanc pyOrthanc clients * Bump version: 3.4.0 → 3.5.0 * #139 Support for pyOrthanc in orthanc-server-extensions * add pyOrthanc dependency for tox * #139 Support for pyOrthanc in orthanc-server-extensions * simplify the enum approach, use better naming * #139 Support for pyOrthanc in orthanc-server-extensions * extend release notes * #139 Fix for changed Enum handling in 3.11
- Loading branch information
1 parent
dd20e2f
commit 8795cb5
Showing
12 changed files
with
113 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
__author__ = """WalkIT""" | ||
__email__ = 'code@walkit.nl' | ||
__version__ = '3.4.0' | ||
__version__ = '3.5.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from enum import Enum | ||
from typing import Union | ||
|
||
import httpx | ||
from pyorthanc import Orthanc, AsyncOrthanc | ||
|
||
from orthanc_ext.http_utilities import OrthancClientTypeFactory | ||
|
||
|
||
class PyOrthancClientType(OrthancClientTypeFactory, Enum): | ||
SYNC = Orthanc | ||
ASYNC = AsyncOrthanc | ||
|
||
def create_internal_client(self, *args, **kwargs): | ||
return create_internal_client(*args, **kwargs, client_type=self) | ||
|
||
|
||
def create_internal_client( | ||
base_url, | ||
token='', | ||
cert: Union[str, bool] = False, | ||
client_type: PyOrthancClientType = PyOrthancClientType.SYNC): | ||
|
||
# note: only difference with the httpx.Client constructor is the `base_url` positional argument. | ||
return client_type.http_client( | ||
base_url, | ||
base_url=base_url, | ||
timeout=httpx.Timeout(300, connect=30), | ||
verify=cert, | ||
headers={'Authorization': token}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[bumpversion] | ||
current_version = 3.4.0 | ||
current_version = 3.5.0 | ||
commit = True | ||
tag = True | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import httpx | ||
|
||
from orthanc_ext.event_dispatcher import create_session | ||
from orthanc_ext.http_utilities import ClientType, HttpxClientType | ||
from orthanc_ext.orthanc import OrthancApiHandler | ||
|
||
|
||
def test_shall_create_sync_client(): | ||
client = HttpxClientType.SYNC.create_internal_client(base_url='http://localhost:8042') | ||
assert client is not None | ||
assert type(client) == httpx.Client | ||
|
||
|
||
def test_shall_support_create_session_for_backward_compatibility(): | ||
assert type(create_session(OrthancApiHandler(), ClientType.SYNC)) == httpx.Client | ||
|
||
|
||
def test_shall_support_create_async_client_for_backward_compatibility(): | ||
assert type(create_session(OrthancApiHandler(), ClientType.ASYNC)) == httpx.AsyncClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from pyorthanc import Orthanc, AsyncOrthanc | ||
|
||
from orthanc_ext.event_dispatcher import create_session | ||
from orthanc_ext.orthanc import OrthancApiHandler | ||
from orthanc_ext.pyorthanc_utilities import PyOrthancClientType | ||
|
||
|
||
def test_shall_create_sync_client(): | ||
client = PyOrthancClientType.SYNC.create_internal_client(base_url='http://localhost:8042') | ||
assert client is not None | ||
assert type(client) == Orthanc | ||
|
||
|
||
def test_shall_create_async_client(): | ||
client = PyOrthancClientType.ASYNC.create_internal_client(base_url='http://localhost:8042') | ||
assert client is not None | ||
assert type(client) == AsyncOrthanc | ||
|
||
|
||
def test_shall_support_create_session_for_backward_compatibility(): | ||
assert create_session(OrthancApiHandler(), PyOrthancClientType.SYNC) is not None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters