Skip to content

Commit bff362a

Browse files
committed
converter tests
1 parent 77b435c commit bff362a

File tree

2 files changed

+59
-33
lines changed

2 files changed

+59
-33
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,27 @@ jobs:
3737
poetry run coverage run --source=filenameprocessor -m unittest discover -s filenameprocessor || echo "filenameprocessor tests failed" >> failed_tests.txt
3838
poetry run coverage xml -o sonarcloud-coverage-filenameprocessor-coverage.xml
3939
40-
- name: Run unittest with recordprocessor-coverage
41-
id: recordprocessor
42-
continue-on-error: true
43-
run: |
44-
poetry run coverage run --source=recordprocessor -m unittest discover -s recordprocessor || echo "recordprocessor tests failed" >> failed_tests.txt
45-
poetry run coverage xml -o sonarcloud-coverage-recordprocessor-coverage.xml
40+
# - name: Run unittest with recordprocessor-coverage
41+
# id: recordprocessor
42+
# continue-on-error: true
43+
# run: |
44+
# poetry run coverage run --source=recordprocessor -m unittest discover -s recordprocessor || echo "recordprocessor tests failed" >> failed_tests.txt
45+
# poetry run coverage xml -o sonarcloud-coverage-recordprocessor-coverage.xml
4646

47-
- name: Run unittest with recordforwarder-coverage
48-
id: recordforwarder
49-
continue-on-error: true
50-
run: |
51-
PYTHONPATH=$(pwd)/backend:$(pwd)/backend/tests poetry run coverage run --source=backend -m unittest discover -s backend/tests -p "*batch*.py" || echo "recordforwarder tests failed" >> failed_tests.txt
52-
poetry run coverage xml -o sonarcloud-coverage-recordforwarder-coverage.xml
47+
# - name: Run unittest with recordforwarder-coverage
48+
# id: recordforwarder
49+
# continue-on-error: true
50+
# run: |
51+
# PYTHONPATH=$(pwd)/backend:$(pwd)/backend/tests poetry run coverage run --source=backend -m unittest discover -s backend/tests -p "*batch*.py" || echo "recordforwarder tests failed" >> failed_tests.txt
52+
# poetry run coverage xml -o sonarcloud-coverage-recordforwarder-coverage.xml
5353

54-
- name: Run unittest with coverage-ack-lambda
55-
id: acklambda
56-
continue-on-error: true
57-
run: |
58-
pip install poetry==1.8.4 coverage moto==4.2.11 freezegun
59-
poetry run coverage run --source=ack_backend -m unittest discover -s ack_backend || echo "ack-lambda tests failed" >> failed_tests.txt
60-
poetry run coverage xml -o sonarcloud-coverage-ack-lambda.xml
54+
# - name: Run unittest with coverage-ack-lambda
55+
# id: acklambda
56+
# continue-on-error: true
57+
# run: |
58+
# pip install poetry==1.8.4 coverage moto==4.2.11 freezegun
59+
# poetry run coverage run --source=ack_backend -m unittest discover -s ack_backend || echo "ack-lambda tests failed" >> failed_tests.txt
60+
# poetry run coverage xml -o sonarcloud-coverage-ack-lambda.xml
6161

6262
- name: Run unittest with coverage-delta
6363
id: delta
@@ -69,21 +69,21 @@ jobs:
6969
poetry run coverage run --source=delta_backend -m unittest discover -s delta_backend || echo "delta tests failed" >> failed_tests.txt
7070
poetry run coverage xml -o sonarcloud-coverage-delta.xml
7171
72-
- name: Run unittest with coverage-fhir-api
73-
id: fhirapi
74-
continue-on-error: true
75-
run: |
76-
pip install poetry==1.8.4 moto==4.2.11 coverage redis botocore==1.35.49 simplejson responses structlog fhir.resources jsonpath_ng pydantic==1.10.13 requests aws-lambda-typing cffi pyjwt boto3-stubs-lite[dynamodb]~=1.26.90 python-stdnum==1.20
77-
poetry run coverage run --source=backend -m unittest discover -s backend || echo "fhir-api tests failed" >> failed_tests.txt
78-
poetry run coverage xml -o sonarcloud-coverage.xml
72+
# - name: Run unittest with coverage-fhir-api
73+
# id: fhirapi
74+
# continue-on-error: true
75+
# run: |
76+
# pip install poetry==1.8.4 moto==4.2.11 coverage redis botocore==1.35.49 simplejson responses structlog fhir.resources jsonpath_ng pydantic==1.10.13 requests aws-lambda-typing cffi pyjwt boto3-stubs-lite[dynamodb]~=1.26.90 python-stdnum==1.20
77+
# poetry run coverage run --source=backend -m unittest discover -s backend || echo "fhir-api tests failed" >> failed_tests.txt
78+
# poetry run coverage xml -o sonarcloud-coverage.xml
7979

80-
- name: Run unittest with coverage-mesh-processor
81-
id: meshprocessor
82-
continue-on-error: true
83-
run: |
84-
pip install poetry==1.8.4 moto==4.2.11 coverage redis botocore==1.35.49 simplejson responses structlog fhir.resources jsonpath_ng pydantic==1.10.13 requests aws-lambda-typing cffi pyjwt boto3-stubs-lite[dynamodb]~=1.26.90 python-stdnum==1.20
85-
poetry run coverage run --source=mesh_processor -m unittest discover -s mesh_processor || echo "mesh_processor tests failed" >> failed_tests.txt
86-
poetry run coverage xml -o sonarcloud-mesh_processor-coverage.xml
80+
# - name: Run unittest with coverage-mesh-processor
81+
# id: meshprocessor
82+
# continue-on-error: true
83+
# run: |
84+
# pip install poetry==1.8.4 moto==4.2.11 coverage redis botocore==1.35.49 simplejson responses structlog fhir.resources jsonpath_ng pydantic==1.10.13 requests aws-lambda-typing cffi pyjwt boto3-stubs-lite[dynamodb]~=1.26.90 python-stdnum==1.20
85+
# poetry run coverage run --source=mesh_processor -m unittest discover -s mesh_processor || echo "mesh_processor tests failed" >> failed_tests.txt
86+
# poetry run coverage xml -o sonarcloud-mesh_processor-coverage.xml
8787

8888
- name: Run Test Failure Summary
8989
id: check_failure
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import unittest
2+
from unittest.mock import patch, MagicMock
3+
from Converter import Converter
4+
5+
class TestConverter(unittest.TestCase):
6+
7+
8+
@patch.object(Converter, '_getFHIRParser')
9+
def test_runConversion_fhirParserException(self, mock_getFHIRParser):
10+
11+
converter = Converter({})
12+
# Arrange: make _getFHIRParser raise an exception
13+
mock_getFHIRParser.side_effect = RuntimeError("Mocked FHIR parser failure")
14+
15+
# Act
16+
result = converter.runConversion(json_data={})
17+
18+
# Assert
19+
self.assertIsInstance(result, dict)
20+
self.assertEqual(result["code"], 0)
21+
self.assertIn("FHIR Parser Unexpected exception", result["message"])
22+
self.assertEqual(len(converter.getErrorRecords()), 1)
23+
self.assertEqual(converter.getErrorRecords()[0], result)
24+
25+
if __name__ == "__main__":
26+
unittest.main()

0 commit comments

Comments
 (0)