Skip to content

Commit

Permalink
added test that updates lambda code with temp function code :)
Browse files Browse the repository at this point in the history
  • Loading branch information
DinisCruz committed Oct 14, 2024
1 parent f32938e commit 16fb8d7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ def invoke(self, params=None):
return self.lambda_function.invoke(params)

def invoke__return_logs(self, params=None):
return self.lambda_function.invoke_return_logs(params)
return self.lambda_function.invoke_return_logs(params)

Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from osbot_utils.utils.Files import path_combine, file_exists, file_contents, file_write

from osbot_utils.utils.Functions import function_source_code

from osbot_utils.utils.Misc import list_set

from osbot_utils.utils.Objects import dict_to_obj
Expand Down Expand Up @@ -31,6 +35,30 @@ def test_invoke__return_logs(self):
assert result.name == 'osbot_local_stack_aws_lambdas_dev_temp_lambda'
assert result.return_value == temp_lambda_return_message

def test_update_lambda_code(self):
def run(event, context):
return 'return dynamic lambda code'

new_source_code = function_source_code(run)

from osbot_utils.utils.Dev import pprint
with self.lambda_function as _:
assert _.invoke() == temp_lambda_return_message # lamda

lambda_file = _.original_name.replace('.','/') + '.py'
lambda_file_path = path_combine(_.folder_code, lambda_file)
assert file_exists(lambda_file_path) is True
file_write(path=lambda_file_path, contents=new_source_code)
assert _.update().get('status') == 'ok'
assert _.wait_for_function_update_to_complete() == 'Successful'
assert _.invoke() == 'return dynamic lambda code'

# with self.deploy_lambda as _:
# pprint(_.obj())
# #
# #_.update()
# #pprint(code)

# def test_create__temp_lambda(self):
# bucket_name = self.s3_bucket
# #pprint(aws_config.region_name())
Expand Down

0 comments on commit 16fb8d7

Please sign in to comment.