@@ -130,10 +130,10 @@ def get_es_documents(self, index, action="index"):
130
130
# Make sure our index is empty before we call the function
131
131
self .assertEqual (ES_INDICES_CLIENT .get_alias ("*" ), {})
132
132
133
- mock_logger = mock .Mock ( spec = [ "info" ])
134
-
135
- with mock . patch . object ( django_timezone , "now" , return_value = now ) :
136
- new_index = perform_create_index (indexable , mock_logger )
133
+ with mock .patch . object (
134
+ django_timezone , "now" , return_value = now
135
+ ), self . assertLogs () as mock_logger :
136
+ new_index = perform_create_index (indexable )
137
137
ES_INDICES_CLIENT .refresh ()
138
138
139
139
self .assertEqual (new_index , "richie_courses_2016-05-04-03h12m33.123456s" )
@@ -151,7 +151,7 @@ def get_es_documents(self, index, action="index"):
151
151
}
152
152
},
153
153
)
154
- mock_logger . info . assert_called ( )
154
+ self . assertNotEqual ( mock_logger . records , [] )
155
155
156
156
@mock .patch .object (
157
157
ES_INDICES .categories ,
@@ -201,7 +201,7 @@ def test_index_manager_regenerate_indices(self, *args):
201
201
creation1_datetime = datetime (2010 , 1 , 1 , tzinfo = timezone .utc )
202
202
creation1_string = creation1_datetime .strftime ("%Y-%m-%d-%Hh%Mm%S.%fs" )
203
203
with mock .patch .object (django_timezone , "now" , return_value = creation1_datetime ):
204
- regenerate_indices (None )
204
+ regenerate_indices ()
205
205
206
206
expected_indices = [
207
207
"richie_test_categories" ,
@@ -223,7 +223,7 @@ def test_index_manager_regenerate_indices(self, *args):
223
223
creation2_datetime = datetime (2011 , 2 , 2 , tzinfo = timezone .utc )
224
224
creation2_string = creation2_datetime .strftime ("%Y-%m-%d-%Hh%Mm%S.%fs" )
225
225
with mock .patch .object (django_timezone , "now" , return_value = creation2_datetime ):
226
- regenerate_indices (None )
226
+ regenerate_indices ()
227
227
228
228
# All indices were replaced and aliases updated
229
229
for alias_name in expected_indices :
@@ -252,7 +252,7 @@ def test_index_manager_regenerate_indices(self, *args):
252
252
creation3_datetime = datetime (2012 , 3 , 3 , tzinfo = timezone .utc )
253
253
creation3_string = creation3_datetime .strftime ("%Y-%m-%d-%Hh%Mm%S.%fs" )
254
254
with mock .patch .object (django_timezone , "now" , return_value = creation3_datetime ):
255
- regenerate_indices (None )
255
+ regenerate_indices ()
256
256
257
257
# All indices were replaced and had their aliases changed
258
258
for index_name in expected_indices :
@@ -314,7 +314,7 @@ def test_index_manager_regenerate_indices_from_broken_state(self, *args):
314
314
creation_datetime = datetime (2010 , 1 , 1 , tzinfo = timezone .utc )
315
315
creation_string = creation_datetime .strftime ("%Y-%m-%d-%Hh%Mm%S.%fs" )
316
316
with mock .patch .object (django_timezone , "now" , return_value = creation_datetime ):
317
- regenerate_indices (None )
317
+ regenerate_indices ()
318
318
319
319
# No error was thrown, the courses index (like all others) was bootstrapped
320
320
self .assertIsNotNone (
@@ -345,7 +345,7 @@ def test_index_manager_store_es_scripts(self, mock_put_script, *args):
345
345
Make sure store_es_scripts iterates over all indexers to store their scripts and
346
346
does not choke when there are (0 | 1 | 2+) scripts on an indexer.
347
347
"""
348
- store_es_scripts (None )
348
+ store_es_scripts ()
349
349
mock_put_script .assert_any_call (body = "script body A" , id = "script_id_A" )
350
350
mock_put_script .assert_any_call (body = "script body B" , id = "script_id_B" )
351
351
mock_put_script .assert_any_call (body = "script body C" , id = "script_id_C" )
0 commit comments