Skip to content

Commit

Permalink
Fix #27, tests not complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
zgypa committed Apr 26, 2024
1 parent cdd1aaf commit 6f927a2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
15 changes: 8 additions & 7 deletions dicom4ortho/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,14 @@ def acquisition_datetime(self, _acquisition_datetime: datetime.datetime):
Also set Acquisition Date and Acquisition Time
"""
if _acquisition_datetime.tzinfo is None:
if self.timezone is not None:
dtz = _acquisition_datetime.replace(tzinfo=self.timezone)
else:
dtz = _acquisition_datetime.astimezone()

dtzs = dtz.strftime(
if _acquisition_datetime.tzinfo is None and self.timezone:
# If no timezone is present and a timezone is specified in the class, add it.
_acquisition_datetime = _acquisition_datetime.replace(tzinfo=self.timezone)
elif _acquisition_datetime.tzinfo is None:
# If no timezone is present and no class timezone, use the current local timezone.
_acquisition_datetime = _acquisition_datetime.astimezone()

dtzs = _acquisition_datetime.strftime(
f"{defaults.DATE_FORMAT}{defaults.TIME_FORMAT}%z")
self._ds.AcquisitionDateTime = dtzs
self._ds.AcquisitionDate = _acquisition_datetime.strftime(
Expand Down
27 changes: 19 additions & 8 deletions test/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,30 @@
@author: Toni Magni
'''
import unittest
from unittest import TestCase
import logging
from dicom4ortho.m_ada1107 import ADA1107
from dicom4ortho.model import DicomBase

class Test(unittest.TestCase):
logging.basicConfig(
format='%(asctime)s - %(levelname)s - %(funcName)s: %(message)s', level=logging.INFO)

def setUp(self):
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(funcName)s: %(message)s',
level=logging.INFO)

class Test(TestCase):

def test_load_views(self):
v = ADA1107()
self.assertEquals(len(v.VIEWS), 74)
self.assertGreater(len(v.VIEWS["VERSION"]),0)
self.assertGreater(len(v.CODES["VERSION"]),0)
logging.info(f'Views ver: [{v.VIEWS["VERSION"]}] Codes ver: [{v.CODES["VERSION"]}]')
self.assertGreater(len(v.VIEWS["VERSION"]), 0)
self.assertGreater(len(v.CODES["VERSION"]), 0)
logging.info(
f'Views ver: [{v.VIEWS["VERSION"]}] Codes ver: [{v.CODES["VERSION"]}]')


class DicomBaseTest(TestCase):
def setUp(self) -> None:
return super().setUp()

def test_acquisition_datetime(self):
db = DicomBase()

0 comments on commit 6f927a2

Please sign in to comment.