-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(datasets): DLHELP-12032 optimize avatar deletion action (#779)
- Loading branch information
Showing
6 changed files
with
73 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
lib/dl_api_lib/dl_api_lib_tests/db/control_api/test_avatars.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from dl_api_lib_tests.db.base import DefaultApiTestBase | ||
|
||
|
||
class TestAvatars(DefaultApiTestBase): | ||
def test_delete_avatar_with_formula_fields(self, control_api, saved_dataset): | ||
ds = saved_dataset | ||
field_count = len(saved_dataset.result_schema) | ||
fields = {f"{field.title}_copy": ds.field(formula=f"[{field.title}]") for field in saved_dataset.result_schema} | ||
for title, field in fields.items(): | ||
ds.result_schema[title] = field | ||
ds = control_api.apply_updates(dataset=ds).dataset | ||
ds = control_api.save_dataset(dataset=ds).dataset | ||
assert len(ds.result_schema) == 2 * field_count | ||
|
||
resp = control_api.apply_updates( | ||
ds, | ||
updates=[ | ||
ds.source_avatars["avatar_1"].delete(), | ||
], | ||
fail_ok=True, | ||
) | ||
assert resp.status_code == 400, resp.json # unknown fields in formulas | ||
|
||
# check that only copies are left | ||
ds = resp.dataset | ||
assert len(ds.result_schema) == field_count | ||
assert all(field.title.endswith("_copy") for field in ds.result_schema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters