@@ -196,7 +196,8 @@ def test_check_quota_countdown():
196
196
197
197
198
198
def test_check_quota ():
199
- self = create_autospec (ArcticLibraryBinding )
199
+ self = create_autospec (ArcticLibraryBinding , database_name = 'arctic_db' ,
200
+ library = 'lib' )
200
201
self .arctic = create_autospec (Arctic )
201
202
self .get_library_metadata .return_value = 1024 * 1024 * 1024
202
203
self .quota_countdown = 0
@@ -208,12 +209,30 @@ def test_check_quota():
208
209
with patch ('arctic.arctic.logger.warning' ) as warn :
209
210
ArcticLibraryBinding .check_quota (self )
210
211
self .arctic .__getitem__ .assert_called_once_with (self .get_name .return_value )
211
- warn .assert_called_once_with ('Mongo Quota: 0.879 / 1 GB used' )
212
+ warn .assert_called_once_with ('Mongo Quota: arctic_db.lib 0.879 / 1 GB used' )
212
213
assert self .quota_countdown == 6
213
214
214
215
216
+ def test_check_quota_90_percent ():
217
+ self = create_autospec (ArcticLibraryBinding , database_name = 'arctic_db' ,
218
+ library = 'lib' )
219
+ self .arctic = create_autospec (Arctic )
220
+ self .get_library_metadata .return_value = 1024 * 1024 * 1024
221
+ self .quota_countdown = 0
222
+ self .arctic .__getitem__ .return_value = Mock (stats = Mock (return_value = {'totals' :
223
+ {'size' : 0.91 * 1024 * 1024 * 1024 ,
224
+ 'count' : 1000000 ,
225
+ }
226
+ }))
227
+ with patch ('arctic.arctic.logger.warning' ) as warn :
228
+ ArcticLibraryBinding .check_quota (self )
229
+ self .arctic .__getitem__ .assert_called_once_with (self .get_name .return_value )
230
+ warn .assert_called_once_with ('Mongo Quota: arctic_db.lib 0.910 / 1 GB used' )
231
+
232
+
215
233
def test_check_quota_info ():
216
- self = create_autospec (ArcticLibraryBinding )
234
+ self = create_autospec (ArcticLibraryBinding , database_name = 'arctic_db' ,
235
+ library = 'lib' )
217
236
self .arctic = create_autospec (Arctic )
218
237
self .get_library_metadata .return_value = 1024 * 1024 * 1024
219
238
self .quota_countdown = 0
@@ -225,12 +244,13 @@ def test_check_quota_info():
225
244
with patch ('arctic.arctic.logger.info' ) as info :
226
245
ArcticLibraryBinding .check_quota (self )
227
246
self .arctic .__getitem__ .assert_called_once_with (self .get_name .return_value )
228
- info .assert_called_once_with ('Mongo Quota: 0.001 / 1 GB used' )
247
+ info .assert_called_once_with ('Mongo Quota: arctic_db.lib 0.001 / 1 GB used' )
229
248
assert self .quota_countdown == 51153
230
249
231
250
232
251
def test_check_quota_exceeded ():
233
- self = create_autospec (ArcticLibraryBinding )
252
+ self = create_autospec (ArcticLibraryBinding , database_name = 'arctic_db' ,
253
+ library = 'lib' )
234
254
self .arctic = create_autospec (Arctic )
235
255
self .get_library_metadata .return_value = 1024 * 1024 * 1024
236
256
self .quota_countdown = 0
@@ -241,7 +261,7 @@ def test_check_quota_exceeded():
241
261
}))
242
262
with pytest .raises (QuotaExceededException ) as e :
243
263
ArcticLibraryBinding .check_quota (self )
244
- assert "Quota Exceeded: 1.000 / 1 GB used" in str (e )
264
+ assert "Quota Exceeded: arctic_db.lib 1.000 / 1 GB used" in str (e )
245
265
246
266
247
267
def test_initialize_library ():
0 commit comments