generated from owasp-sbot/OSBot__Repo_Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started adding lamdba/workflows/s3_events
- Loading branch information
Showing
4 changed files
with
50 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from osbot_local_stack.utils.Version import version__osbot_local_stack | ||
import requests | ||
|
||
def run(event, context): | ||
return f'current version: {version__osbot_local_stack}' | ||
result = requests.get('https://httpbin.org/get') | ||
return f'{result.status_code}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 44 additions & 11 deletions
55
tests/integration/aws/lambdas/workflows/test_s3_events.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,55 @@ | ||
import pytest | ||
|
||
from osbot_utils.utils.Env import set_env | ||
|
||
from osbot_aws.deploy.Deploy_Lambda import Deploy_Lambda | ||
|
||
from osbot_aws.AWS_Config import aws_config | ||
|
||
from osbot_aws.aws.lambda_.Lambda import Lambda | ||
|
||
from osbot_local_stack.testing.TestCase__Local_Stack import TestCase__Local_Stack | ||
from osbot_utils.utils.Dev import pprint | ||
from osbot_local_stack.aws.lambdas.workflows.s3_events import run | ||
from osbot_local_stack.utils.Version import version__osbot_local_stack | ||
from osbot_local_stack.testing.TestCase__Local_Stack__Temp_Lambda import TestCase__Local_Stack__Temp_Lambda | ||
|
||
class test_hello_world(TestCase__Local_Stack__Temp_Lambda): | ||
from osbot_local_stack.testing.TestCase__Local_Stack__Temp_Lambda import TestCase__Local_Stack__Temp_Lambda, \ | ||
LAMBDA__DEPENDENCIES__REQUESTS | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.lambda_handler = run | ||
super().setUpClass() | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
super().tearDownClass() | ||
class test_s3_events__create_bucket_and_lambda(TestCase__Local_Stack__Temp_Lambda): | ||
lambda_handler = run | ||
#delete_after_run = False | ||
|
||
@classmethod | ||
def create_temp_lambda(cls): | ||
cls.deploy_lambda.add_osbot_utils() | ||
cls.deploy_lambda.add_modules(LAMBDA__DEPENDENCIES__REQUESTS) | ||
super().create_temp_lambda() | ||
|
||
def test_invoke(self): | ||
assert self.lambda_function.invoke() == f'current version: {version__osbot_local_stack}' | ||
response = self.lambda_function.invoke() | ||
assert response == '200' | ||
|
||
@pytest.mark.skip("Only for local development") | ||
class test_s3_events(TestCase__Local_Stack): | ||
aws_region = 'sa-east-1' #'ap-south-1' | ||
s3_bucket = "local-stack-jfpzjbftqgxd" | ||
lambda_handler = run | ||
|
||
def setUp(self): | ||
set_env('OSBOT_LAMBDA_S3_BUCKET', self.s3_bucket) | ||
|
||
def test_invoke(self): | ||
|
||
with Deploy_Lambda(handler=self.lambda_handler) as _: | ||
_.add_osbot_utils() | ||
_.add_modules(LAMBDA__DEPENDENCIES__REQUESTS) | ||
_.update() | ||
response = _.invoke() | ||
pprint(response) | ||
|
||
# *** Skipping delete Lambda function: osbot_local_stack.aws.lambdas.workflows.s3_events | ||
# *** Skipping delete bucket *** | ||
# *** bucket name: local-stack-jfpzjbftqgxd | ||
# *** region name: sa-east-1 | ||
|