|
1 | | -import json |
2 | 1 | import os |
3 | 2 | import unittest |
4 | | -from copy import deepcopy |
5 | 3 | from datetime import datetime |
6 | 4 | from unittest.mock import patch |
7 | 5 |
|
8 | 6 | from boto3 import resource as boto3_resource |
9 | 7 | from moto import mock_aws |
10 | 8 |
|
11 | | -from common.fhir_to_flat_json.converter import Converter |
12 | 9 | from common.fhir_to_flat_json.mappings import ActionFlag, EventName, Operation |
13 | | -from utils_for_converter_tests import ErrorValuesForTests, ValuesForTests |
| 10 | +from utils import ValuesForTests |
14 | 11 |
|
15 | 12 | MOCK_ENV_VARS = { |
16 | 13 | "AWS_SQS_QUEUE_URL": "https://sqs.eu-west-2.amazonaws.com/123456789012/test-queue", |
@@ -136,74 +133,6 @@ def assert_dynamodb_record( |
136 | 133 | expires_at = unfiltered_items[0]["ExpiresAt"] |
137 | 134 | self.assertEqual(expires_at - date_time, expected_seconds) |
138 | 135 |
|
139 | | - def test_fhir_converter_json_direct_data(self): |
140 | | - """it should convert fhir json data to flat json""" |
141 | | - json_data = json.dumps(ValuesForTests.json_data) |
142 | | - |
143 | | - fhir_converter = Converter(json_data) |
144 | | - FlatFile = fhir_converter.run_conversion() |
145 | | - |
146 | | - flatJSON = json.dumps(FlatFile) |
147 | | - expected_imms_value = deepcopy(ValuesForTests.expected_imms2) # UPDATE is currently the default action-flag |
148 | | - expected_imms = json.dumps(expected_imms_value) |
149 | | - self.assertEqual(flatJSON, expected_imms) |
150 | | - |
151 | | - errorRecords = fhir_converter.get_error_records() |
152 | | - |
153 | | - self.assertEqual(len(errorRecords), 0) |
154 | | - |
155 | | - def test_fhir_converter_json_error_scenario_reporting_on(self): |
156 | | - """it should convert fhir json data to flat json - error scenarios""" |
157 | | - error_test_cases = [ |
158 | | - ErrorValuesForTests.missing_json, |
159 | | - ErrorValuesForTests.json_dob_error, |
160 | | - ] |
161 | | - |
162 | | - for test_case in error_test_cases: |
163 | | - json_data = json.dumps(test_case) |
164 | | - |
165 | | - fhir_converter = Converter(json_data) |
166 | | - fhir_converter.run_conversion() |
167 | | - |
168 | | - errorRecords = fhir_converter.get_error_records() |
169 | | - |
170 | | - # Check if bad data creates error records |
171 | | - self.assertTrue(len(errorRecords) > 0) |
172 | | - |
173 | | - def test_fhir_converter_json_error_scenario_reporting_off(self): |
174 | | - """it should convert fhir json data to flat json - error scenarios""" |
175 | | - error_test_cases = [ |
176 | | - ErrorValuesForTests.missing_json, |
177 | | - ErrorValuesForTests.json_dob_error, |
178 | | - ] |
179 | | - |
180 | | - for test_case in error_test_cases: |
181 | | - json_data = json.dumps(test_case) |
182 | | - |
183 | | - fhir_converter = Converter(json_data, report_unexpected_exception=False) |
184 | | - fhir_converter.run_conversion() |
185 | | - |
186 | | - errorRecords = fhir_converter.get_error_records() |
187 | | - |
188 | | - # Check if bad data creates error records |
189 | | - self.assertTrue(len(errorRecords) == 0) |
190 | | - |
191 | | - def test_fhir_converter_json_incorrect_data_scenario_reporting_on(self): |
192 | | - """it should convert fhir json data to flat json - error scenarios""" |
193 | | - |
194 | | - with self.assertRaises(ValueError): |
195 | | - fhir_converter = Converter(None) |
196 | | - errorRecords = fhir_converter.get_error_records() |
197 | | - self.assertTrue(len(errorRecords) > 0) |
198 | | - |
199 | | - def test_fhir_converter_json_incorrect_data_scenario_reporting_off(self): |
200 | | - """it should convert fhir json data to flat json - error scenarios""" |
201 | | - |
202 | | - with self.assertRaises(ValueError): |
203 | | - fhir_converter = Converter(None, report_unexpected_exception=False) |
204 | | - errorRecords = fhir_converter.get_error_records() |
205 | | - self.assertTrue(len(errorRecords) == 0) |
206 | | - |
207 | 136 | def test_handler_imms_convert_to_flat_json(self): |
208 | 137 | """Test that the Imms field contains the correct flat JSON data for CREATE, UPDATE, and DELETE operations.""" |
209 | 138 | expected_action_flags = [ |
|
0 commit comments