@@ -89,50 +89,48 @@ def __prepare__(cls, name, this_bases):
89
89
return type .__new__ (metaclass , 'temporary_class' , (), {})
90
90
91
91
92
- class SpecTestUtil (object ):
93
- @staticmethod
94
- def is_run_on_requirement_satisfied (requirement ):
95
- topology_satisfied = True
96
- req_topologies = requirement .get ('topologies' )
97
- if req_topologies :
98
- topology_satisfied = client_context .is_topology_type (
99
- req_topologies )
100
-
101
- min_version_satisfied = True
102
- req_min_server_version = requirement .get ('minServerVersion' )
103
- if req_min_server_version :
104
- min_version_satisfied = Version .from_string (
105
- req_min_server_version ) <= client_context .version
106
-
107
- max_version_satisfied = True
108
- req_max_server_version = requirement .get ('maxServerVersion' )
109
- if req_max_server_version :
110
- max_version_satisfied = Version .from_string (
111
- req_max_server_version ) >= client_context .version
112
-
113
- return (topology_satisfied and min_version_satisfied and
114
- max_version_satisfied )
92
+ def is_run_on_requirement_satisfied (requirement ):
93
+ topology_satisfied = True
94
+ req_topologies = requirement .get ('topologies' )
95
+ if req_topologies :
96
+ topology_satisfied = client_context .is_topology_type (
97
+ req_topologies )
115
98
116
- @staticmethod
117
- def parse_collection_or_database_options (options ):
118
- return parse_collection_options (options )
99
+ min_version_satisfied = True
100
+ req_min_server_version = requirement .get ('minServerVersion' )
101
+ if req_min_server_version :
102
+ min_version_satisfied = Version .from_string (
103
+ req_min_server_version ) <= client_context .version
119
104
120
- @staticmethod
121
- def parse_bulk_write_result (result ):
122
- upserted_ids = {str (int_idx ): result .upserted_ids [int_idx ]
123
- for int_idx in result .upserted_ids }
124
- return {
125
- 'deletedCount' : result .deleted_count ,
126
- 'insertedCount' : result .inserted_count ,
127
- 'matchedCount' : result .matched_count ,
128
- 'modifiedCount' : result .modified_count ,
129
- 'upsertedCount' : result .upserted_count ,
130
- 'upsertedIds' : upserted_ids }
105
+ max_version_satisfied = True
106
+ req_max_server_version = requirement .get ('maxServerVersion' )
107
+ if req_max_server_version :
108
+ max_version_satisfied = Version .from_string (
109
+ req_max_server_version ) >= client_context .version
131
110
132
- @staticmethod
133
- def parse_bulk_write_error_result (error ):
134
- write_result = BulkWriteResult (error .details , True )
135
- return SpecTestUtil .parse_bulk_write_result (write_result )
111
+ return (topology_satisfied and min_version_satisfied and
112
+ max_version_satisfied )
113
+
114
+
115
+ def parse_collection_or_database_options (options ):
116
+ return parse_collection_options (options )
117
+
118
+
119
+ def parse_bulk_write_result (result ):
120
+ upserted_ids = {str (int_idx ): result .upserted_ids [int_idx ]
121
+ for int_idx in result .upserted_ids }
122
+ return {
123
+ 'deletedCount' : result .deleted_count ,
124
+ 'insertedCount' : result .inserted_count ,
125
+ 'matchedCount' : result .matched_count ,
126
+ 'modifiedCount' : result .modified_count ,
127
+ 'upsertedCount' : result .upserted_count ,
128
+ 'upsertedIds' : upserted_ids }
129
+
130
+
131
+ def parse_bulk_write_error_result (error ):
132
+ write_result = BulkWriteResult (error .details , True )
133
+ return parse_bulk_write_result (write_result )
136
134
137
135
138
136
class EventListenerUtil (CommandListener ):
@@ -213,7 +211,7 @@ def _create_entity(self, entity_spec):
213
211
self ._test_class .fail (
214
212
'Expected entity %s to be of type MongoClient, got %s' % (
215
213
spec ['client' ], type (client )))
216
- options = SpecTestUtil . parse_collection_or_database_options (
214
+ options = parse_collection_or_database_options (
217
215
spec .get ('databaseOptions' , {}))
218
216
self [spec ['id' ]] = client .get_database (
219
217
spec ['databaseName' ], ** options )
@@ -224,7 +222,7 @@ def _create_entity(self, entity_spec):
224
222
self ._test_class .fail (
225
223
'Expected entity %s to be of type Database, got %s' % (
226
224
spec ['database' ], type (database )))
227
- options = SpecTestUtil . parse_collection_or_database_options (
225
+ options = parse_collection_or_database_options (
228
226
spec .get ('collectionOptions' , {}))
229
227
self [spec ['id' ]] = database .get_collection (
230
228
spec ['collectionName' ], ** options )
@@ -250,7 +248,7 @@ def _create_entity(self, entity_spec):
250
248
elif entity_type == 'bucket' :
251
249
# TODO: implement the 'bucket' entity type
252
250
self ._test_class .skipTest (
253
- 'GridFS entity types are not currently supported. ' )
251
+ 'GridFS is not currently supported (PYTHON-2459) ' )
254
252
self ._test_class .fail (
255
253
'Unable to create entity of unknown type %s' % (entity_type ,))
256
254
@@ -515,7 +513,7 @@ def should_run_on(run_on_spec):
515
513
return True
516
514
517
515
for req in run_on_spec :
518
- if SpecTestUtil . is_run_on_requirement_satisfied (req ):
516
+ if is_run_on_requirement_satisfied (req ):
519
517
return True
520
518
return False
521
519
0 commit comments