Fixing bug in DbMemory.del_list(), where if you passed a filter to delete the whole... 43/6043/1
authorEduardo Sousa <eduardosousa@av.it.pt>
Thu, 26 Apr 2018 14:55:05 +0000 (15:55 +0100)
committerEduardo Sousa <eduardosousa@av.it.pt>
Thu, 26 Apr 2018 14:55:05 +0000 (15:55 +0100)
Change-Id: I1282bd637567ca651ffcd201edfc8ff9fd0950d7
Signed-off-by: Eduardo Sousa <eduardosousa@av.it.pt>
osm_common/dbmemory.py
osm_common/tests/test_dbmemory.py

index d7419f4..6f7e4c4 100644 (file)
@@ -64,7 +64,7 @@ class DbMemory(DbBase):
             for i, _ in self._find(table, self._format_filter(filter)):
                 id_list.append(i)
             deleted = len(id_list)
-            for i in id_list:
+            for i in reversed(id_list):
                 del self.db[table][i]
             return {"deleted": deleted}
         except DbException:
index 0b62485..f73c317 100644 (file)
@@ -217,7 +217,7 @@ def test_get_one_generic_exception(db_memory_with_data):
     assert excinfo.value.http_code == http.HTTPStatus.NOT_FOUND
 
 @pytest.mark.parametrize("table, filter, expected_data", [
-#    ("test", {}, []),
+    ("test", {}, []),
     ("test", {"_id": 1}, [{"_id": 2, "data": 2}, {"_id": 3, "data": 3}]), 
     ("test", {"_id": 2}, [{"_id": 1, "data": 1}, {"_id": 3, "data": 3}]), 
     ("test", {"_id": 1, "data": 1}, [{"_id": 2, "data": 2}, {"_id": 3, "data": 3}]),