Skip to content

Commit daf1890

Browse files
committed
less v
1 parent d08deb3 commit daf1890

File tree

2 files changed

+107
-107
lines changed

2 files changed

+107
-107
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 88 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,106 @@
11
name: SonarCloud
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
8-
types: [labeled, opened, synchronize, reopened, unlabeled]
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types: [labeled, opened, synchronize, reopened, unlabeled]
99

1010
jobs:
11-
sonarcloud:
12-
name: SonarCloud
13-
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependency') }}
14-
runs-on: ubuntu-latest
11+
sonarcloud:
12+
name: SonarCloud
13+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependency') }}
14+
runs-on: ubuntu-latest
1515

16-
steps:
17-
- uses: actions/checkout@v4
18-
with:
19-
fetch-depth: 0
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
2020

21-
- name: Set up AWS credentials
22-
env:
23-
AWS_ACCESS_KEY_ID: "FOOBARKEY"
24-
AWS_SECRET_ACCESS_KEY: "FOOBARSECRET"
25-
run: |
26-
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
27-
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
21+
- name: Set up AWS credentials
22+
env:
23+
AWS_ACCESS_KEY_ID: "FOOBARKEY"
24+
AWS_SECRET_ACCESS_KEY: "FOOBARSECRET"
25+
run: |
26+
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
27+
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
2828
29-
- name: Initialize Unit Test Failure Tracker
30-
run: echo "false" > test_failed.txt
29+
- name: Initialize Unit Test Failure Tracker
30+
run: echo "false" > test_failed.txt
3131

32-
# - name: Run unittest with filenameprocessor-coverage
33-
# id: filenameprocessor
34-
# continue-on-error: true
35-
# run: |
36-
# pip install poetry==1.8.4 moto==4.2.11 coverage redis botocore==1.35.49 simplejson pandas freezegun 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 fakeredis
37-
# poetry run coverage run --source=filenameprocessor -m unittest discover -s filenameprocessor || echo "filenameprocessor tests failed" >> failed_tests.txt
38-
# poetry run coverage xml -o sonarcloud-coverage-filenameprocessor-coverage.xml
32+
# - name: Run unittest with filenameprocessor-coverage
33+
# id: filenameprocessor
34+
# continue-on-error: true
35+
# run: |
36+
# pip install poetry==1.8.4 moto==4.2.11 coverage redis botocore==1.35.49 simplejson pandas freezegun 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 fakeredis
37+
# poetry run coverage run --source=filenameprocessor -m unittest discover -s filenameprocessor || echo "filenameprocessor tests failed" >> failed_tests.txt
38+
# 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

62-
- name: Run unittest with coverage-delta
63-
id: delta
64-
continue-on-error: true
65-
run: |
66-
pip install poetry==1.8.4 mypy-boto3-dynamodb==1.35.54 boto3==1.26.165 coverage botocore==1.29.165 jmespath==1.0.1 python-dateutil==2.9.0 urllib3==1.26.20 s3transfer==0.6.2 typing-extensions==4.12.2
67-
poetry run coverage run --source=delta_backend -m unittest discover -s delta_backend -v || echo "delta tests failed" >> failed_tests.txt
68-
poetry run coverage xml -o sonarcloud-coverage-delta.xml
62+
- name: Run unittest with coverage-delta
63+
id: delta
64+
continue-on-error: true
65+
run: |
66+
pip install poetry==1.8.4 mypy-boto3-dynamodb==1.35.54 boto3==1.26.165 coverage botocore==1.29.165 jmespath==1.0.1 python-dateutil==2.9.0 urllib3==1.26.20 s3transfer==0.6.2 typing-extensions==4.12.2
67+
poetry run coverage run --source=delta_backend -m unittest discover -s delta_backend || echo "delta tests failed" >> failed_tests.txt
68+
poetry run coverage xml -o sonarcloud-coverage-delta.xml
6969
70-
# - name: Run unittest with coverage-fhir-api
71-
# id: fhirapi
72-
# continue-on-error: true
73-
# run: |
74-
# 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
75-
# poetry run coverage run --source=backend -m unittest discover -s backend || echo "fhir-api tests failed" >> failed_tests.txt
76-
# poetry run coverage xml -o sonarcloud-coverage.xml
70+
# - name: Run unittest with coverage-fhir-api
71+
# id: fhirapi
72+
# continue-on-error: true
73+
# run: |
74+
# 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
75+
# poetry run coverage run --source=backend -m unittest discover -s backend || echo "fhir-api tests failed" >> failed_tests.txt
76+
# poetry run coverage xml -o sonarcloud-coverage.xml
7777

78-
# - name: Run unittest with coverage-mesh-processor
79-
# id: meshprocessor
80-
# continue-on-error: true
81-
# run: |
82-
# 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
83-
# poetry run coverage run --source=mesh_processor -m unittest discover -s mesh_processor || echo "mesh_processor tests failed" >> failed_tests.txt
84-
# poetry run coverage xml -o sonarcloud-mesh_processor-coverage.xml
78+
# - name: Run unittest with coverage-mesh-processor
79+
# id: meshprocessor
80+
# continue-on-error: true
81+
# run: |
82+
# 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
83+
# poetry run coverage run --source=mesh_processor -m unittest discover -s mesh_processor || echo "mesh_processor tests failed" >> failed_tests.txt
84+
# poetry run coverage xml -o sonarcloud-mesh_processor-coverage.xml
8585

86-
- name: Run Test Failure Summary
87-
id: check_failure
88-
run: |
89-
if [ -s failed_tests.txt ]; then
90-
echo "The following tests failed:"
91-
cat failed_tests.txt
86+
- name: Run Test Failure Summary
87+
id: check_failure
88+
run: |
89+
if [ -s failed_tests.txt ]; then
90+
echo "The following tests failed:"
91+
cat failed_tests.txt
9292
93-
while IFS= read -r line; do
94-
echo "##[error]Test Failures: $line"
95-
done < failed_tests.txt
96-
97-
exit 1
98-
else
99-
echo "All tests passed."
100-
fi
93+
while IFS= read -r line; do
94+
echo "##[error]Test Failures: $line"
95+
done < failed_tests.txt
96+
97+
exit 1
98+
else
99+
echo "All tests passed."
100+
fi
101101
102-
- name: SonarCloud Scan
103-
uses: SonarSource/sonarqube-scan-action@master
104-
env:
105-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
106-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
102+
- name: SonarCloud Scan
103+
uses: SonarSource/sonarqube-scan-action@master
104+
env:
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
106+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

delta_backend/tests/test_log_firehose.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,28 @@ def test_send_log(self, mock_boto_client):
4646
self.assertEqual(mock_firehose_client.put_record.return_value, mock_response)
4747

4848
@patch("boto3.client") # Mock boto3.client
49-
def test_send_log_failure(self, mock_boto_client):
50-
"""Test that send_log logs an exception when put_record fails."""
51-
# Arrange
52-
mock_firehose_client = MagicMock()
53-
mock_boto_client.return_value = mock_firehose_client
54-
mock_firehose_client.put_record.side_effect = Exception("Test exception")
49+
def test_send_log_failure(self, mock_boto_client):
50+
"""Test that send_log logs an exception when put_record fails."""
51+
# Arrange
52+
mock_firehose_client = MagicMock()
53+
mock_boto_client.return_value = mock_firehose_client
54+
mock_firehose_client.put_record.side_effect = Exception("Test exception")
5555

56-
stream_name = "test-stream"
57-
firehose_logger = FirehoseLogger(boto_client=mock_firehose_client, stream_name=stream_name)
58-
log_message = {"key": "value"}
56+
stream_name = "test-stream"
57+
firehose_logger = FirehoseLogger(boto_client=mock_firehose_client, stream_name=stream_name)
58+
log_message = {"key": "value"}
5959

60-
# Mock logger.exception
61-
with patch("src.log_firehose.logger.exception") as mock_logger_exception:
62-
# Act
63-
firehose_logger.send_log(log_message)
60+
# Mock logger.exception
61+
with patch("src.log_firehose.logger.exception") as mock_logger_exception:
62+
# Act
63+
firehose_logger.send_log(log_message)
6464

65-
# Assert
66-
mock_firehose_client.put_record.assert_called_once_with(
67-
DeliveryStreamName="test-stream",
68-
Record={"Data": json.dumps(log_message).encode("utf-8")},
69-
)
70-
mock_logger_exception.assert_called_once_with("Error sending log to Firehose: Test exception")
65+
# Assert
66+
mock_firehose_client.put_record.assert_called_once_with(
67+
DeliveryStreamName="test-stream",
68+
Record={"Data": json.dumps(log_message).encode("utf-8")},
69+
)
70+
mock_logger_exception.assert_called_once_with("Error sending log to Firehose: Test exception")
7171

7272
if __name__ == "__main__":
7373
unittest.main()

0 commit comments

Comments
 (0)