# HG changeset patch # User Sebastien Jodogne # Date 1497274485 -7200 # Node ID 5b6812f8cc38f69f874507d93bb5b97491f6ee80 # Parent 7aee4cc64fca98e65d2772b09272ebbbcd5809fd worklists: test_bitbucket_issue_49 diff -r 7aee4cc64fca -r 5b6812f8cc38 Database/Worklists/Encodings/issue49-latin1.query --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Database/Worklists/Encodings/issue49-latin1.query Mon Jun 12 15:34:45 2017 +0200 @@ -0,0 +1,1 @@ +(0010,0010) PN [*] diff -r 7aee4cc64fca -r 5b6812f8cc38 Plugins/Worklists/Run.py --- a/Plugins/Worklists/Run.py Sat Jun 10 11:07:26 2017 +0200 +++ b/Plugins/Worklists/Run.py Mon Jun 12 15:34:45 2017 +0200 @@ -29,6 +29,7 @@ import sys import tempfile import unittest +from shutil import copyfile sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'Tests')) from Toolbox import * @@ -92,10 +93,16 @@ if f != 'lockfile': os.remove(os.path.join(WORKING, f)) -def AddToDatabase(source): - subprocess.check_call([ 'dump2dcm', '--write-xfer-little', - os.path.join(DATABASE, source), - os.path.join(WORKING, os.path.basename(source) + '.wl') ]) +def AddToDatabase(worklist): + extension = os.path.splitext(worklist)[1].lower() + source = os.path.join(DATABASE, worklist) + target = os.path.join(WORKING, os.path.basename(worklist) + '.wl') + + if extension == '.dump': + subprocess.check_call([ 'dump2dcm', '--write-xfer-little', source, target ]) + else: + copyfile(source, target) + def RunQuery(source, ignoreTags): with tempfile.NamedTemporaryFile() as f: @@ -273,8 +280,21 @@ self.assertEqual(encoded, tags['0010,0010']) + def test_bitbucket_issue_49(self): + def Check(encoding, expectedEncoding, expectedContent): + DoPut(ORTHANC, '/tools/default-encoding', encoding) + result = RunQuery('Encodings/issue49-latin1.query', []) + self.assertEqual(1, len(result)) + self.assertEqual(2, len(result[0])) + tags = ParseTopLevelTags(result[0]) + self.assertEqual(expectedEncoding, tags['0008,0005']) + self.assertEqual(expectedContent, tags['0010,0010']) - + AddToDatabase('Encodings/issue49-latin1.wl') + Check('Ascii', 'ISO_IR 6', r'VANILL^LAURA^^^Mme') + Check('Utf8', 'ISO_IR 192', r'VANILLÉ^LAURA^^^Mme') + Check('Latin1', 'ISO_IR 100', u'VANILLÉ^LAURA^^^Mme'.encode('latin-1', 'ignore')) + try: print('\nStarting the tests...') unittest.main(argv = [ sys.argv[0] ] + args.options)