@@ -89,6 +89,7 @@ def test_get_empty(self, app, url, institutional_admin):
8989 assert _resp .json ['data' ] == []
9090
9191 def test_get_reports (self , app , url , institutional_admin , institution , reports , unshown_reports ):
92+ InstitutionalUserReport ._get_connection ().indices .refresh (InstitutionalUserReport ._template_pattern )
9293 _resp = app .get (url , auth = institutional_admin .auth )
9394 assert _resp .status_code == 200
9495 assert len (_resp .json ['data' ]) == len (reports )
@@ -100,6 +101,7 @@ def test_get_reports(self, app, url, institutional_admin, institution, reports,
100101 assert len (response_object ['attributes' ]['contacts' ]) == 0
101102
102103 def test_filter_reports (self , app , url , institutional_admin , institution , reports , unshown_reports ):
104+ InstitutionalUserReport ._get_connection ().indices .refresh (InstitutionalUserReport ._template_pattern )
103105 for _query , _expected_user_ids in (
104106 ({'filter[department]' : 'nunavum' }, set ()),
105107 ({'filter[department]' : 'incidentally' }, set ()),
@@ -135,6 +137,7 @@ def test_filter_reports(self, app, url, institutional_admin, institution, report
135137 assert set (_user_ids (_resp )) == _expected_user_ids
136138
137139 def test_sort_reports (self , app , url , institutional_admin , institution , reports , unshown_reports ):
140+ InstitutionalUserReport ._get_connection ().indices .refresh (InstitutionalUserReport ._template_pattern )
138141 for _query , _expected_user_id_list in (
139142 ({'sort' : 'storage_byte_count' }, ['u_sparse' , 'u_orc' , 'u_blargl' , 'u_orcomma' ]),
140143 ({'sort' : '-storage_byte_count' }, ['u_orcomma' , 'u_blargl' , 'u_orc' , 'u_sparse' ]),
@@ -144,6 +147,7 @@ def test_sort_reports(self, app, url, institutional_admin, institution, reports,
144147 assert list (_user_ids (_resp )) == _expected_user_id_list
145148
146149 def test_paginate_reports (self , app , url , institutional_admin , institution , reports , unshown_reports ):
150+ InstitutionalUserReport ._get_connection ().indices .refresh (InstitutionalUserReport ._template_pattern )
147151 for _query , _expected_user_id_list in (
148152 ({'sort' : 'storage_byte_count' , 'page[size]' : 2 }, ['u_sparse' , 'u_orc' ]),
149153 ({'sort' : 'storage_byte_count' , 'page[size]' : 2 , 'page' : 2 }, ['u_blargl' , 'u_orcomma' ]),
@@ -178,6 +182,7 @@ def test_get_report_formats_csv_tsv(self, app, url, institutional_admin, institu
178182 month_last_active = '2018-02' ,
179183 month_last_login = '2018-02' ,
180184 )
185+ InstitutionalUserReport ._get_connection ().indices .refresh (InstitutionalUserReport ._template_pattern )
181186
182187 resp = app .get (f'{ url } ?format={ format_type } ' , auth = institutional_admin .auth )
183188 assert resp .status_code == 200
@@ -281,6 +286,7 @@ def test_csv_tsv_ignores_pagination(self, app, url, institutional_admin, institu
281286 str (736662999298 + i ),
282287 f'Jalen Hurts #{ i } ' ,
283288 ])
289+ InstitutionalUserReport ._get_connection ().indices .refresh (InstitutionalUserReport ._template_pattern )
284290
285291 # Make request for CSV format with page[size]=10
286292 resp = app .get (f'{ url } ?format={ format_type } ' , auth = institutional_admin .auth )
@@ -346,6 +352,7 @@ def test_get_report_format_table_json(self, app, url, institutional_admin, insti
346352 month_last_active = '2018-02' ,
347353 month_last_login = '2018-02' ,
348354 )
355+ InstitutionalUserReport ._get_connection ().indices .refresh (InstitutionalUserReport ._template_pattern )
349356
350357 resp = app .get (f'{ url } ?format=json_report' , auth = institutional_admin .auth )
351358 assert resp .status_code == 200
@@ -411,6 +418,7 @@ def test_correct_number_of_contact_messages(self, app, url, institutional_admin,
411418 department_name = 'a department, or so, that happens, incidentally, to have commas' ,
412419 storage_byte_count = 736662999298 ,
413420 )
421+ InstitutionalUserReport ._get_connection ().indices .refresh (InstitutionalUserReport ._template_pattern )
414422
415423 receiver = user1
416424 with capture_notifications ():
@@ -477,5 +485,5 @@ def _report_factory(yearmonth, institution, **kwargs):
477485 institution_id = institution ._id ,
478486 ** kwargs ,
479487 )
480- _report .save (refresh = True )
488+ _report .save ()
481489 return _report
0 commit comments