def test_remove_nipsa_gets_query(nipsa_search, _): worker.add_or_remove_nipsa(client=mock.Mock(), index="foo", userid="test_userid", action="remove_nipsa") nipsa_search.nipsad_annotations.assert_called_once_with("test_userid")
def test_remove_nipsa_passes_query_to_scan(nipsa_search, helpers): query = mock.MagicMock() nipsa_search.nipsad_annotations.return_value = query worker.add_or_remove_nipsa("test_userid", "remove_nipsa", mock.Mock()) assert helpers.scan.call_args[1]["query"] == query
def test_add_nipsa_passes_actions_to_bulk(_, helpers): helpers.scan.return_value = [ {"_id": "foo"}, {"_id": "bar"}, {"_id": "gar"}] worker.add_or_remove_nipsa("test_userid", "add_nipsa", mock.Mock()) actions = helpers.bulk.call_args[1]["actions"] assert [action["_id"] for action in actions] == ["foo", "bar", "gar"]
def test_remove_nipsa_passes_es_client_to_scan(_, helpers): client = mock.Mock() worker.add_or_remove_nipsa(client=client, index="foo", userid="test_userid", action="remove_nipsa") assert helpers.scan.call_args[1]["client"] == client
def test_remove_nipsa_passes_query_to_scan(nipsa_search, helpers): query = mock.MagicMock() nipsa_search.nipsad_annotations.return_value = query worker.add_or_remove_nipsa(client=mock.Mock(), index="foo", userid="test_userid", action="remove_nipsa") assert helpers.scan.call_args[1]["query"] == query
def test_remove_nipsa_passes_actions_to_bulk(_, helpers): helpers.scan.return_value = [{ "_id": "foo" }, { "_id": "bar" }, { "_id": "gar" }] worker.add_or_remove_nipsa(client=mock.Mock(), index="foo", userid="test_userid", action="remove_nipsa") actions = helpers.bulk.call_args[1]["actions"] assert [action["_id"] for action in actions] == ["foo", "bar", "gar"]
def test_remove_nipsa_passes_es_client_to_scan(_, helpers): es_client = mock.Mock() worker.add_or_remove_nipsa("test_userid", "remove_nipsa", es_client) assert helpers.scan.call_args[1]["client"] == es_client
def test_remove_nipsa_gets_query(nipsa_search, _): worker.add_or_remove_nipsa("test_userid", "remove_nipsa", mock.Mock()) nipsa_search.nipsad_annotations.assert_called_once_with("test_userid")
def test_remove_nipsa_passes_actions_to_bulk(_, helpers): es_client = mock.Mock() worker.add_or_remove_nipsa("test_userid", "remove_nipsa", es_client) assert helpers.bulk.call_args[1]["client"] == es_client