Skip to content

Commit

Permalink
tests: remove main code in md5
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjermiah committed Feb 5, 2024
1 parent b90c74c commit 2972b5f
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions src/nbiatoolkit/utils/md5.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,41 +37,4 @@ def validateMD5(seriesDir: str) -> bool:

# delete the md5 file if all hashes match
os.remove(md5File)
return True


if __name__ == "__main__":
import sys
import io
import os
import zipfile
from nbiatoolkit.utils.nbia_endpoints import NBIA_ENDPOINTS
from nbiatoolkit import NBIAClient
import requests
from tempfile import TemporaryDirectory

client = NBIAClient()
series = "1.3.6.1.4.1.14519.5.2.1.6834.5010.189721824525842725510380467695"
query_url = NBIA_ENDPOINTS.BASE_URL.value + NBIA_ENDPOINTS.DOWNLOAD_SERIES.value

params = dict()
params["SeriesInstanceUID"] = series

response = requests.get(url=query_url, headers=client.api_headers, params=params)

file = zipfile.ZipFile(io.BytesIO(response.content))

tempDir_ = TemporaryDirectory()
tempDir = tempDir_.name

file.extractall(path=tempDir)

try:
validateMD5(tempDir)
print("MD5 hashes validated successfully.")
except AssertionError as e:
print(f"Error validating MD5 hashes: {e}")
sys.exit(1)
except FileNotFoundError as e:
print(f"Error validating MD5 hashes: {e}")
sys.exit(1)
return True

0 comments on commit 2972b5f

Please sign in to comment.