-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: addig facade for collection creation
- Loading branch information
Showing
5 changed files
with
110 additions
and
61 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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import json | ||
|
||
from cumulus_lambda_functions.lib.aws.aws_cred import AwsCred | ||
|
||
|
||
class AwsLambda(AwsCred): | ||
def __init__(self): | ||
super().__init__() | ||
self.__lambda_client = self.get_client('lambda') | ||
|
||
def invoke_function(self, function_name: str, payload: dict): | ||
response = self.__lambda_client.invoke( | ||
FunctionName=function_name, | ||
InvocationType='Event', # 'Event' = async | 'RequestResponse' = sync | 'DryRun', | ||
LogType='None', # 'None' = async | 'Tail = sync', | ||
ClientContext='', # Up to 3583 bytes of base64-encoded data | ||
Payload=json.dumps(payload).encode(), | ||
# Qualifier='string' | ||
) | ||
return response |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from datetime import datetime | ||
from unittest import TestCase | ||
|
||
from cumulus_lambda_functions.cumulus_stac.unity_collection_stac import UnityCollectionStac | ||
from cumulus_lambda_functions.lib.aws.aws_lambda import AwsLambda | ||
|
||
|
||
class TestAwsLambda(TestCase): | ||
def test_01(self): | ||
dapa_collection = UnityCollectionStac() \ | ||
.with_id(f'CUMULUS_DAPA_UNIT_TEST___{int(datetime.utcnow().timestamp())}') \ | ||
.with_graule_id_regex("^P[0-9]{3}[0-9]{4}[A-Z]{13}T[0-9]{12}0$") \ | ||
.with_granule_id_extraction_regex("(P[0-9]{3}[0-9]{4}[A-Z]{13}T[0-9]{12}0).+") \ | ||
.with_title("P1570515ATMSSCIENCEAXT11344000000001.PDS") \ | ||
.with_process('modis') \ | ||
.add_file_type("P1570515ATMSSCIENCEAXT11344000000000.PDS.cmr.xml", | ||
"^P[0-9]{3}[0-9]{4}[A-Z]{13}T[0-9]{12}00.PDS.cmr.xml$", 'internal', 'metadata', 'item') \ | ||
.add_file_type("P1570515ATMSSCIENCEAXT11344000000001.PDS.xml", | ||
"^P[0-9]{3}[0-9]{4}[A-Z]{13}T[0-9]{12}01\\.PDS\\.xml$", 'internal', 'metadata', 'item') \ | ||
.add_file_type("P1570515ATMSSCIENCEAXT11344000000000.PDS", "^P[0-9]{3}[0-9]{4}[A-Z]{13}T[0-9]{12}00\\.PDS$", | ||
'internal', 'data', 'item') | ||
stac_collection = dapa_collection.start() | ||
|
||
response = AwsLambda().invoke_function( | ||
function_name='am-uds-dev-cumulus-cumulus_collections_creation_dapa', | ||
payload=stac_collection, | ||
) | ||
self.assertTrue('ResponseMetadata' in response, f'missing ResponseMetadata in response {response}') | ||
self.assertTrue('HTTPStatusCode' in response['ResponseMetadata'], f'missing HTTPStatusCode in response#ResponseMetadata {response}') | ||
print(response) | ||
return |
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