Skip to content

Commit 9ef7f10

Browse files
Add conf_path module and update event_gate_lambda for configuration resolution
1 parent a32bd5d commit 9ef7f10

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed

src/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Copyright 2025 ABSA Group Limited
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#

src/event_gate_lambda.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@
2727
from jsonschema import validate
2828
from jsonschema.exceptions import ValidationError
2929

30-
from . import conf_path # new import for CONF_DIR resolution
31-
try: # fallback if relative import fails (e.g., executed as a script)
32-
from . import conf_path as _conf_mod
33-
except Exception: # pragma: no cover
34-
import conf_path as _conf_mod
35-
conf_path = _conf_mod
36-
37-
# Remove old resolution logic, use module instead
38-
_CONF_DIR = conf_path.CONF_DIR
39-
_INVALID_CONF_ENV = conf_path.INVALID_CONF_ENV
30+
try:
31+
from .conf_path import CONF_DIR, INVALID_CONF_ENV
32+
except ImportError: # fallback when executed outside package context
33+
from conf_path import CONF_DIR, INVALID_CONF_ENV
34+
35+
# Use imported symbols for internal variables
36+
_CONF_DIR = CONF_DIR
37+
_INVALID_CONF_ENV = INVALID_CONF_ENV
4038

4139
sys.path.append(os.path.join(os.path.dirname(__file__)))
4240

tests/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#
2+
# Copyright 2025 ABSA Group Limited
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
import os, sys
17+
# Ensure project root is on sys.path so 'src' package is importable during tests
18+
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
19+
if PROJECT_ROOT not in sys.path:
20+
sys.path.insert(0, PROJECT_ROOT)

0 commit comments

Comments
 (0)