Skip to content

Commit

Permalink
fix: tests Add error handling for response code 204 and fix typo in t…
Browse files Browse the repository at this point in the history
…est_getDICOMTags
  • Loading branch information
jjjermiah committed Feb 18, 2024
1 parent 17df239 commit c8968da
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/nbiatoolkit/utils/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def parse_response(response: requests.Response) -> List[dict[Any, Any]]:
assert (
response.status_code == 200
), "The response status code must be 200 OK but is {}".format(response.status_code)
# TODO:: describe error 204

if not "application/json" in content_type:
if response.content == b"":
Expand Down
14 changes: 14 additions & 0 deletions tests/test_nbia_series_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ def getSeriesMetadata(nbia_client):
return series_metadata


def test_getSeriesMetadata_failed(nbia_client):
with pytest.raises(Exception) as e:
series = "1.3.6.1.4.1..1.9203.4004.652695091345533290618011349477"
series_metadata = nbia_client.getSeriesMetadata(
SeriesInstanceUID=series, return_type="dataframe"
)


@pytest.fixture(scope="session")
def getNewSeries_metadata(nbia_client):
Date = "01/01/2024"
Expand Down Expand Up @@ -90,6 +98,12 @@ def test_failed_getNewPatients(nbia_client):
)


def test_failed_getDICOMTags(nbia_client):
with pytest.raises(Exception) as e:
# collection isntead of Collection
nbia_client.getDICOMTags(series="ShouldFail", return_type="dataframe")


def test_getNewPatients(nbia_patients_df):

assert isinstance(nbia_patients_df, pd.DataFrame)
Expand Down
7 changes: 6 additions & 1 deletion tests/test_parsers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from src.nbiatoolkit.utils.parsers import clean_html, convertMillis, convertDateFormat
from src.nbiatoolkit.utils.parsers import (
clean_html,
convertMillis,
convertDateFormat,
parse_response,
)
from datetime import datetime
import pytest

Expand Down

0 comments on commit c8968da

Please sign in to comment.