diff --git a/lemur/database.py b/lemur/database.py index 6de3d964..c2bb8f13 100644 --- a/lemur/database.py +++ b/lemur/database.py @@ -176,8 +176,9 @@ def delete(model): :param model: """ - db.session.delete(model) - db.session.commit() + if model: + db.session.delete(model) + db.session.commit() def filter(query, model, terms): diff --git a/lemur/tests/test_destinations.py b/lemur/tests/test_destinations.py index 4274bbe4..37da1299 100644 --- a/lemur/tests/test_destinations.py +++ b/lemur/tests/test_destinations.py @@ -78,7 +78,7 @@ def test_admin_destination_put(client): def test_admin_destination_delete(client): - assert client.delete(api.url_for(Destinations, destination_id=1), headers=VALID_ADMIN_HEADER_TOKEN).status_code == 500 + assert client.delete(api.url_for(Destinations, destination_id=1), headers=VALID_ADMIN_HEADER_TOKEN).status_code == 200 def test_admin_destination_patch(client):