def test_custom_filename(self): """ if the ModelAdmin has `get_export_as_csv_filename()` use that method to get the attachment filename """ with user_grant_permission(self.user, ['auth.change_user', 'auth.adminactions_export_user']): res = self.app.get('/', user='******') with admin_register(User) as md: with mock.patch.object(md, 'get_export_as_csv_filename', lambda r, q: 'new.test', create=True): res = res.click('Users') form = res.forms['changelist-form'] form['action'] = 'export_as_csv' form.set('_selected_action', True, 0) form['select_across'] = 1 res = form.submit() res = res.form.submit('apply') self.assertEqual(res.content_disposition, u'attachment;filename="new.test"')
def test_custom_filename(self): """ if the ModelAdmin has `get_export_as_csv_filename()` use that method to get the attachment filename """ with user_grant_permission( self.user, ['auth.change_user', 'auth.adminactions_export_user']): res = self.app.get('/', user='******') with admin_register(User) as md: with mock.patch.object(md, 'get_export_as_csv_filename', lambda r, q: 'new.test', create=True): res = res.click('Users') form = res.forms['changelist-form'] form['action'] = 'export_as_csv' form.set('_selected_action', True, 0) form['select_across'] = 1 res = form.submit() res = res.form.submit('apply') self.assertEqual(res.content_disposition, u'attachment;filename="new.test"')