Skip to content

Commit

Permalink
Add tests for orthanc_sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
gacou54 committed Oct 18, 2023
1 parent 23224ae commit a146234
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 31 deletions.
9 changes: 7 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
version: '3.3'
services:
orthanc1:
image: jodogne/orthanc:1.12.1
build:
dockerfile: tests/orthanc/orthanc-for-test.Dockerfile
context: .
environment:
PYTHON_PLUGIN_ENABLE: "true"
ORTHANC__PYTHON_SCRIPT: "/python/script.py"
depends_on:
- orthanc2
orthanc2:
Expand All @@ -12,4 +17,4 @@ services:
dockerfile: pytest.Dockerfile
depends_on:
- orthanc1
- orthanc2
- orthanc2
11 changes: 0 additions & 11 deletions tests/data/config/config-1.json

This file was deleted.

8 changes: 0 additions & 8 deletions tests/data/config/config-2.json

This file was deleted.

6 changes: 6 additions & 0 deletions tests/orthanc/orthanc-for-test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM osimis/orthanc:22.6.1

RUN pip install httpx pydicom

COPY pyorthanc /python/pyorthanc
COPY tests/orthanc/script.py /python/script.py
8 changes: 8 additions & 0 deletions tests/orthanc/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from pyorthanc import orthanc_sdk


def on_get(output: orthanc_sdk.RestOutput, *_, **__):
output.AnswerBuffer('ok', 'text/plain')


orthanc_sdk.RegisterRestCallback('/test', on_get)
11 changes: 1 addition & 10 deletions tests/setup_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import dataclasses
import subprocess
import os

import httpx

Expand All @@ -9,28 +8,20 @@
class OrthancServer:
url: str
AeT: str
config_path: str
storage_path: str
test_data_path: str
username: str = 'orthanc'
password: str = 'orthanc'

process: subprocess.Popen = None


ORTHANC_1 = OrthancServer(
url=f'http://orthanc1:8042',
AeT='ORTHANC',
storage_path='./tests/data/config/OrthancStorage-1',
config_path='./tests/data/config/config-1.json',
test_data_path='./tests/data/orthanc_1_test_data',
)

ORTHANC_2 = OrthancServer(
url=f'http://orthanc2:8042',
AeT='ORTHANC',
storage_path='./tests/data/config/OrthancStorage-2',
config_path='./tests/data/config/config-2.json',
test_data_path='./tests/data/orthanc_2_test_data',
)

Expand Down
10 changes: 10 additions & 0 deletions tests/test_orthanc_sdk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from http import HTTPStatus

from .setup_server import ORTHANC_1


def test_new_route(client):
response = client.get(f'{ORTHANC_1.url}/test')

assert response.status_code == HTTPStatus.OK
assert response.text == 'ok'

0 comments on commit a146234

Please sign in to comment.