1919logger = logging .getLogger (__name__ )
2020
2121
22- class TestPyMongo (unittest .TestCase ):
22+ class TestPyMongoTracer (unittest .TestCase ):
2323 def setUp (self ):
2424 self .conn = pymongo .MongoClient (host = testenv ['mongodb_host' ], port = int (testenv ['mongodb_port' ]),
2525 username = testenv ['mongodb_user' ], password = testenv ['mongodb_pw' ])
@@ -107,11 +107,11 @@ def test_successful_update_query(self):
107107
108108 payload = json .loads (db_span .data ["mongo" ]["json" ])
109109 assert_true ({
110- "q" : {"type" : "string" },
111- "u" : {"$set" : {"type" : "int" }},
112- "multi" : False ,
113- "upsert" : False
114- } in payload , db_span .data ["mongo" ]["json" ])
110+ "q" : {"type" : "string" },
111+ "u" : {"$set" : {"type" : "int" }},
112+ "multi" : False ,
113+ "upsert" : False
114+ } in payload , db_span .data ["mongo" ]["json" ])
115115
116116 def test_successful_delete_query (self ):
117117 with tracer .start_active_span ("test" ):
@@ -174,7 +174,8 @@ def test_successful_map_reduce_query(self):
174174 reducer = "function (key, values) { return len(values); }"
175175
176176 with tracer .start_active_span ("test" ):
177- self .conn .test .records .map_reduce (bson .code .Code (mapper ), bson .code .Code (reducer ), "results" , query = {"x" : {"$lt" : 2 }})
177+ self .conn .test .records .map_reduce (bson .code .Code (mapper ), bson .code .Code (reducer ), "results" ,
178+ query = {"x" : {"$lt" : 2 }})
178179
179180 assert_is_none (tracer .active_span )
180181
@@ -192,7 +193,8 @@ def test_successful_map_reduce_query(self):
192193 self .assertEqual (db_span .n , "mongo" )
193194 self .assertEqual (db_span .data ["mongo" ]["service" ], "%s:%s" % (testenv ['mongodb_host' ], testenv ['mongodb_port' ]))
194195 self .assertEqual (db_span .data ["mongo" ]["namespace" ], "test.records" )
195- self .assertEqual (db_span .data ["mongo" ]["command" ].lower (), "mapreduce" ) # mapreduce command was renamed to mapReduce in pymongo 3.9.0
196+ self .assertEqual (db_span .data ["mongo" ]["command" ].lower (),
197+ "mapreduce" ) # mapreduce command was renamed to mapReduce in pymongo 3.9.0
196198
197199 self .assertEqual (db_span .data ["mongo" ]["filter" ], '{"x": {"$lt": 2}}' )
198200 assert_is_not_none (db_span .data ["mongo" ]["json" ])
@@ -228,3 +230,4 @@ def test_successful_mutiple_queries(self):
228230
229231 # ensure spans are ordered the same way as commands
230232 assert_list_equal (commands , ["insert" , "update" , "delete" ])
233+
0 commit comments