def test_index_manager_regenerate_indexes_with_empty_index(self, *args): """ Make sure `regenerate_indexes` still works when there are no existing indexes. This test case was added to reproduce a bug. """ regenerate_indexes(None) self.indices_client.update_aliases.assert_called_with({ "actions": [ { "add": { "index": "richie_example_created_index", "alias": "richie_example", } }, { "add": { "index": "richie_stub_created_index", "alias": "richie_stub", } }, { "add": { "index": "richie_stub_created_index", "alias": "richie_stub", } }, ] }) self.indices_client.delete.assert_not_called()
def test_index_manager_regenerate_indexes(self, *args): """ Now test the general index regeneration behavior. We don't need to test the side-effects again as those have mostly been tested through perform_create_index. We mostly have to ensure the proper calls happen and the correct actions/deletions are passed to the indices_client. """ regenerate_indexes(None) self.indices_client.update_aliases.assert_called_with({ "actions": [ { "add": { "index": "richie_example_created_index", "alias": "richie_example", } }, { "add": { "index": "richie_stub_created_index", "alias": "richie_stub", } }, { "add": { "index": "richie_stub_created_index", "alias": "richie_stub", } }, { "remove": { "index": "richie_example_forgotten", "alias": "richie_example", } }, { "remove": { "index": "richie_example_previous", "alias": "richie_example", } }, { "remove": { "index": "richie_stub_forgotten", "alias": "richie_stub", } }, { "remove": { "index": "richie_stub_previous", "alias": "richie_stub", } }, { "remove": { "index": "richie_stub_forgotten", "alias": "richie_stub", } }, { "remove": { "index": "richie_stub_previous", "alias": "richie_stub", } }, ] }) self.indices_client.delete.assert_called_with(ignore=[400, 404], index="richie_orphan")