[refactor] start decoupling backend code from aws wrapper
Browse files
dockerfiles/dockerfile-lambda-fastsam-api
CHANGED
@@ -31,4 +31,4 @@ RUN ls -l /lambda-entrypoint.sh
|
|
31 |
RUN ls -l ${LAMBDA_TASK_ROOT}/src/
|
32 |
|
33 |
# ENTRYPOINT ["/lambda-entrypoint.sh"]
|
34 |
-
CMD [ "src.
|
|
|
31 |
RUN ls -l ${LAMBDA_TASK_ROOT}/src/
|
32 |
|
33 |
# ENTRYPOINT ["/lambda-entrypoint.sh"]
|
34 |
+
CMD [ "src.io.lambda_wrapper.lambda_handler" ]
|
src/{app.py → io/lambda_wrapper.py}
RENAMED
File without changes
|
tests/test_app.py
CHANGED
@@ -5,16 +5,15 @@ from unittest.mock import patch
|
|
5 |
|
6 |
from awslambdaric.lambda_context import LambdaContext
|
7 |
|
8 |
-
from src import
|
9 |
-
from src.io import lambda_helpers
|
10 |
from tests.local_tiles_http_server import LocalTilesHttpServer
|
11 |
|
12 |
|
13 |
class TestAppFailures(unittest.TestCase):
|
14 |
@patch.object(time, "time")
|
15 |
-
@patch.object(
|
16 |
-
@patch.object(
|
17 |
-
@patch.object(
|
18 |
def test_lambda_handler_500(
|
19 |
self,
|
20 |
get_parsed_request_body_mocked,
|
@@ -22,7 +21,7 @@ class TestAppFailures(unittest.TestCase):
|
|
22 |
samexporter_predict_mocked,
|
23 |
time_mocked
|
24 |
):
|
25 |
-
from src.
|
26 |
|
27 |
time_mocked.return_value = 0
|
28 |
get_parsed_request_body_mocked.value = {}
|
@@ -43,9 +42,9 @@ class TestAppFailures(unittest.TestCase):
|
|
43 |
assert lambda_handler(event, lambda_context) == expected_response_500
|
44 |
|
45 |
@patch.object(time, "time")
|
46 |
-
@patch.object(
|
47 |
def test_lambda_handler_400(self, get_parsed_request_body_mocked, time_mocked):
|
48 |
-
from src.
|
49 |
|
50 |
time_mocked.return_value = 0
|
51 |
get_parsed_request_body_mocked.return_value = {}
|
@@ -65,7 +64,7 @@ class TestAppFailures(unittest.TestCase):
|
|
65 |
|
66 |
@patch.object(time, "time")
|
67 |
def test_lambda_handler_422(self, time_mocked):
|
68 |
-
from src.
|
69 |
|
70 |
time_mocked.return_value = 0
|
71 |
event = {"body": {}, "version": 1.0}
|
@@ -84,10 +83,10 @@ class TestAppFailures(unittest.TestCase):
|
|
84 |
assert response_422 == expected_response_422
|
85 |
|
86 |
@patch.object(time, "time")
|
87 |
-
@patch.object(
|
88 |
-
@patch.object(
|
89 |
-
@patch.object(
|
90 |
-
@patch.object(
|
91 |
def test_lambda_handler_200_mocked(
|
92 |
self,
|
93 |
get_parsed_request_body_mocked,
|
@@ -96,7 +95,7 @@ class TestAppFailures(unittest.TestCase):
|
|
96 |
samexporter_predict_mocked,
|
97 |
time_mocked
|
98 |
):
|
99 |
-
from src.
|
100 |
from tests import TEST_EVENTS_FOLDER
|
101 |
|
102 |
time_mocked.return_value = 0
|
@@ -146,7 +145,7 @@ class TestAppFailures(unittest.TestCase):
|
|
146 |
import xyzservices
|
147 |
import shapely
|
148 |
|
149 |
-
from src.
|
150 |
from tests import LOCAL_URL_TILE, TEST_EVENTS_FOLDER
|
151 |
|
152 |
local_tile_provider = xyzservices.TileProvider(name="local_tile_provider", url=LOCAL_URL_TILE, attribution="")
|
@@ -191,7 +190,7 @@ class TestAppFailures(unittest.TestCase):
|
|
191 |
assert len(output_geojson.geoms) == expected_response_body["n_shapes_geojson"]
|
192 |
|
193 |
def test_debug(self):
|
194 |
-
from src.
|
195 |
|
196 |
input_event = {
|
197 |
'bbox': {
|
|
|
5 |
|
6 |
from awslambdaric.lambda_context import LambdaContext
|
7 |
|
8 |
+
from src.io import lambda_helpers, lambda_wrapper
|
|
|
9 |
from tests.local_tiles_http_server import LocalTilesHttpServer
|
10 |
|
11 |
|
12 |
class TestAppFailures(unittest.TestCase):
|
13 |
@patch.object(time, "time")
|
14 |
+
@patch.object(lambda_wrapper, "samexporter_predict")
|
15 |
+
@patch.object(lambda_wrapper, "get_parsed_bbox_points")
|
16 |
+
@patch.object(lambda_wrapper, "get_parsed_request_body")
|
17 |
def test_lambda_handler_500(
|
18 |
self,
|
19 |
get_parsed_request_body_mocked,
|
|
|
21 |
samexporter_predict_mocked,
|
22 |
time_mocked
|
23 |
):
|
24 |
+
from src.io.lambda_wrapper import lambda_handler
|
25 |
|
26 |
time_mocked.return_value = 0
|
27 |
get_parsed_request_body_mocked.value = {}
|
|
|
42 |
assert lambda_handler(event, lambda_context) == expected_response_500
|
43 |
|
44 |
@patch.object(time, "time")
|
45 |
+
@patch.object(lambda_wrapper, "get_parsed_request_body")
|
46 |
def test_lambda_handler_400(self, get_parsed_request_body_mocked, time_mocked):
|
47 |
+
from src.io.lambda_wrapper import lambda_handler
|
48 |
|
49 |
time_mocked.return_value = 0
|
50 |
get_parsed_request_body_mocked.return_value = {}
|
|
|
64 |
|
65 |
@patch.object(time, "time")
|
66 |
def test_lambda_handler_422(self, time_mocked):
|
67 |
+
from src.io.lambda_wrapper import lambda_handler
|
68 |
|
69 |
time_mocked.return_value = 0
|
70 |
event = {"body": {}, "version": 1.0}
|
|
|
83 |
assert response_422 == expected_response_422
|
84 |
|
85 |
@patch.object(time, "time")
|
86 |
+
@patch.object(lambda_wrapper, "samexporter_predict")
|
87 |
+
@patch.object(lambda_wrapper, "get_response")
|
88 |
+
@patch.object(lambda_wrapper, "get_parsed_bbox_points")
|
89 |
+
@patch.object(lambda_wrapper, "get_parsed_request_body")
|
90 |
def test_lambda_handler_200_mocked(
|
91 |
self,
|
92 |
get_parsed_request_body_mocked,
|
|
|
95 |
samexporter_predict_mocked,
|
96 |
time_mocked
|
97 |
):
|
98 |
+
from src.io.lambda_wrapper import lambda_handler
|
99 |
from tests import TEST_EVENTS_FOLDER
|
100 |
|
101 |
time_mocked.return_value = 0
|
|
|
145 |
import xyzservices
|
146 |
import shapely
|
147 |
|
148 |
+
from src.io.lambda_wrapper import lambda_handler
|
149 |
from tests import LOCAL_URL_TILE, TEST_EVENTS_FOLDER
|
150 |
|
151 |
local_tile_provider = xyzservices.TileProvider(name="local_tile_provider", url=LOCAL_URL_TILE, attribution="")
|
|
|
190 |
assert len(output_geojson.geoms) == expected_response_body["n_shapes_geojson"]
|
191 |
|
192 |
def test_debug(self):
|
193 |
+
from src.io.lambda_wrapper import lambda_handler
|
194 |
|
195 |
input_event = {
|
196 |
'bbox': {
|