Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): do not allow areas, links or thermals deletion when referenced in a binding constraint #2061

Merged

Conversation

mabw-rte
Copy link
Contributor

@mabw-rte mabw-rte commented Jun 10, 2024

context:
When an object is deleted while being referenced in a binding constraint, this may cause the study to become corrupt.

Acceptance tests

List of endpoints affected by the changes and to be tested:

  • PUT /v1/studies/{uuid}/table-mode/binding-constraints: Update binding constraints from Table Mode,
  • PUT /v1/studies/{uuid}/bindingconstraints/{binding_constraint_id}: Update binding constraint,
  • POST /v1/studies/{uuid}/bindingconstraints: Create a binding constraint,
  • DELETE /v1/studies/{uuid}/areas/{area_id}/clusters/thermal: Remove thermal clusters for a given area,
  • DELETE /v1//studies/{uuid}/links/{area_from}/{area_to}: Delete a link,
  • DELETE /v1/studies/{uuid}/areas/{area_id}: Delete an area.

@mabw-rte mabw-rte self-assigned this Jun 10, 2024
@laurent-laporte-pro laurent-laporte-pro changed the title feat(delete-apis): not allow deletion for areas, links and thermals when referenced in a bc feat(api): do not allow areas, links or thermals deletion when referenced in a binding constraint Jun 10, 2024
@mabw-rte mabw-rte force-pushed the feature/1789-stop-deletion-for-bcs-referenced-objs branch 2 times, most recently from 96f14d9 to eade1f4 Compare June 12, 2024 10:24
Copy link
Contributor

@MartinBelthle MartinBelthle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code prevents the front-end to remove links/areas/clusters but not the scripts as they use the commands.

Looking at the code I don't think there's a nice way to implement it (PUT /commands on a variant only add the command to the variant commands list without any verification for instance).

I think we can keep this how it is and not support the verification for /commands, what do you think @laurent-laporte-pro ?

tests/integration/test_integration.py Outdated Show resolved Hide resolved
tests/integration/test_integration.py Outdated Show resolved Hide resolved
tests/integration/study_data_blueprint/test_thermal.py Outdated Show resolved Hide resolved
tests/integration/study_data_blueprint/test_thermal.py Outdated Show resolved Hide resolved
antarest/study/service.py Outdated Show resolved Hide resolved
antarest/study/service.py Outdated Show resolved Hide resolved
antarest/study/service.py Outdated Show resolved Hide resolved
@mabw-rte mabw-rte force-pushed the feature/1789-stop-deletion-for-bcs-referenced-objs branch 2 times, most recently from 5e81a71 to c393a53 Compare June 18, 2024 13:48
@laurent-laporte-pro laurent-laporte-pro force-pushed the feature/1789-stop-deletion-for-bcs-referenced-objs branch from 75096fc to 476f051 Compare June 21, 2024 15:56
@laurent-laporte-pro
Copy link
Contributor

@mabw-rte

J'ai effectué un refactoring au niveau de la gestion des exceptions pour n'avoir qu'une seule classe d'exception BindingConstraintDeletionNotAllowed : il y avait de la duplication de code. Aussi, j'ai un peu changé le message d'erreur.

Au niveau des fonctions qui contrôlent les objets référencés par des contraintes couplantes, j'ai amélioré ou ajouté une docstring. Le raise a aussi été adapté en fonction des paramètres du constructeur de l'exception BindingConstraintDeletionNotAllowed (ajout du paramètre object_type).

J'ai ajouté des tests unitaires pour avoir une meilleure couverture de tests, notamment dans le cas de la suppression d'une zone.

J'ai fait aussi quelques corrections annexes qui m'ont été remontées par SonarCloud.

antarest/study/service.py Fixed Show fixed Hide fixed
@mabw-rte mabw-rte force-pushed the feature/1789-stop-deletion-for-bcs-referenced-objs branch from 69735d1 to dd3761c Compare June 24, 2024 14:49
antarest/study/service.py Fixed Show resolved Hide resolved
@laurent-laporte-pro laurent-laporte-pro force-pushed the feature/1789-stop-deletion-for-bcs-referenced-objs branch from a46229b to bddfaa3 Compare June 24, 2024 21:54
antarest/study/service.py Dismissed Show dismissed Hide dismissed
@laurent-laporte-pro laurent-laporte-pro merged commit b195aa0 into dev Jun 24, 2024
7 of 8 checks passed
@laurent-laporte-pro laurent-laporte-pro deleted the feature/1789-stop-deletion-for-bcs-referenced-objs branch June 24, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants