File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -54,5 +54,37 @@ def test_connect_uri(self):
54
54
client .get_database ().test .find_one ()
55
55
56
56
57
+ class TestAWSLambdaExamples (unittest .TestCase ):
58
+ def test_shared_client (self ):
59
+ # Start AWS Lambda Example 1
60
+ import os
61
+
62
+ from pymongo import MongoClient
63
+
64
+ client = MongoClient (host = os .environ ["MONGODB_URI" ])
65
+
66
+ def lambda_handler (event , context ):
67
+ return client .db .command ("ping" )
68
+
69
+ # End AWS Lambda Example 1
70
+
71
+ def test_IAM_auth (self ):
72
+ # Start AWS Lambda Example 2
73
+ import os
74
+
75
+ from pymongo import MongoClient
76
+
77
+ client = MongoClient (
78
+ host = os .environ ["MONGODB_URI" ],
79
+ authSource = "$external" ,
80
+ authMechanism = "MONGODB-AWS" ,
81
+ )
82
+
83
+ def lambda_handler (event , context ):
84
+ return client .db .command ("ping" )
85
+
86
+ # End AWS Lambda Example 2
87
+
88
+
57
89
if __name__ == "__main__" :
58
90
unittest .main ()
You can’t perform that action at this time.
0 commit comments