Skip to content

Commit 2de2d83

Browse files
committed
common.clients
toml sonarqube shared path id sync path sonarQube duplicate ignore
1 parent 7b2be5e commit 2de2d83

24 files changed

+1251
-31
lines changed

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ updates:
5959
- "/recordprocessor"
6060
- "/redis_sync"
6161
- "/lambdas/id_sync"
62+
- "/lambdas/shared"
6263
schedule:
6364
interval: "daily"
6465
open-pull-requests-limit: 1

.github/workflows/sonarcloud.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
pull_request:
88
types: [labeled, opened, synchronize, reopened, unlabeled]
99

10+
env:
11+
SHARED_PATH: ${{ github.workspace }}/lambdas/shared/src:${{ github.workspace }}/lambdas/shared/tests
12+
LAMBDA_PATH: ${{ github.workspace }}/lambdas
13+
1014
jobs:
1115
sonarcloud:
1216
name: SonarCloud
@@ -26,6 +30,11 @@ jobs:
2630
3.10
2731
3.11
2832
cache: 'poetry'
33+
- name: Debug shared folder
34+
run: |
35+
echo "Showing shared/src/common structure:"
36+
ls
37+
ls -R lambdas/shared/src/common || echo "Directory missing"
2938
3039
- name: Set up AWS credentials
3140
env:
@@ -124,11 +133,23 @@ jobs:
124133
poetry run coverage run -m unittest discover || echo "redis_sync tests failed" >> ../failed_tests.txt
125134
poetry run coverage xml -o ../redis_sync-coverage.xml
126135
136+
- name: Run unittest with shared
137+
working-directory: lambdas/shared
138+
id: shared
139+
env:
140+
PYTHONPATH: ${{ env.SHARED_PATH }}
141+
continue-on-error: true
142+
run: |
143+
poetry env use 3.11
144+
poetry install
145+
poetry run coverage run -m unittest discover || echo "shared tests failed" >> ../../failed_tests.txt
146+
poetry run coverage xml -o ../../shared-coverage.xml
147+
127148
- name: Run unittest with id_sync
128149
working-directory: lambdas/id_sync
129150
id: id_sync
130151
env:
131-
PYTHONPATH: ${{ github.workspace }}/lambdas/id_sync/src:${{ github.workspace }}/lambdas/id_sync/tests
152+
PYTHONPATH: ${{ env.LAMBDA_PATH }}/id_sync/src:${{ env.LAMBDA_PATH }}/id_sync/tests:${{ env.SHARED_PATH }}
132153
continue-on-error: true
133154
run: |
134155
poetry env use 3.11

immunisation-fhir-api.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
},
3333
{
3434
"path": "lambdas/id_sync"
35+
},
36+
{
37+
"path": "lambdas/shared"
3538
}
3639
],
3740
"settings": {},

lambdas/id_sync/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
TEST_ENV := @PYTHONPATH=src:tests:../shared/src
12

23
test:
3-
@PYTHONPATH=src:tests:../shared/src python -m unittest
4+
$(TEST_ENV) python -m unittest
45

56
coverage-run:
6-
coverage run -m unittest discover -v
7+
$(TEST_ENV) coverage run -m unittest discover -v
78

89
coverage-report:
9-
coverage report -m
10+
$(TEST_ENV) coverage report -m
1011

1112
coverage-html:
12-
coverage html
13+
$(TEST_ENV) coverage html
14+
1315

1416
.PHONY: build package

lambdas/id_sync/pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[project]
2-
name = "redis-sync"
2+
name = "id-sync"
33
version = "0.1.0"
44
description = "Sync s3 to REDIS"
55
authors = [
66
{name = "nhsdevws",email = "[email protected]"}
77
]
88

99
[tool.poetry]
10-
name = "redis-sync"
10+
name = "id-sync"
1111
version = "0.1.0"
1212
description = ""
1313
authors = ["s.wates <[email protected]>"]
1414
readme = "README.md"
1515
packages = [
1616
{include = "src"},
17-
{include = "common", from = "../shared/src/common"}
17+
{include = "common", from = "../shared/src"}
1818
]
1919

2020
[tool.poetry.dependencies]

lambdas/id_sync/src/clients.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

lambdas/id_sync/src/id_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from common.clients import logger
2-
from clients import STREAM_NAME
2+
from common.clients import STREAM_NAME
33
from common.log_decorator import logging_decorator
44
from record_processor import process_record
55

lambdas/id_sync/src/record_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55

66
def process_record(record, _):
7-
return "hello world"
7+
return f"hello world {record}"

lambdas/id_sync/tests/test_handler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def setUp(self):
1616
self.record_processor_patcher = patch("id_sync.process_record")
1717
self.mock_record_processor = self.record_processor_patcher.start()
1818
# patch log_decorator to pass through
19-
self.mock_log_decorator = patch("common.log_decorator.logging_decorator", lambda prefix=None: (lambda f: f)).start()
19+
self.mock_log_decorator = patch("common.log_decorator.logging_decorator",
20+
lambda prefix=None: (lambda f: f)).start()
2021

2122
def tearDown(self):
2223
patch.stopall()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from record_processor import process_record
2+
import unittest
3+
from unittest.mock import patch
4+
5+
6+
class TestRecordProcessor(unittest.TestCase):
7+
def setUp(self):
8+
self.logger_info_patcher = patch("logging.Logger.info")
9+
self.mock_logger_info = self.logger_info_patcher.start()
10+
11+
def tearDown(self):
12+
patch.stopall()
13+
14+
def test_record_processor_success(self):
15+
test_record = "abc1"
16+
response = process_record(test_record, None)
17+
self.assertEqual(response, f"hello world {test_record}")

0 commit comments

Comments
 (0)