Skip to content

Commit

Permalink
Update unit test for create_applied_controls_from_suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Sep 26, 2024
1 parent 252ac29 commit 97e7c72
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions backend/core/tests/test_requirement_assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,27 @@ def test_create_applied_controls_from_suggestions(self):

for requirement_assessment in requirement_assessments:
requirement_assessment.create_applied_controls_from_suggestions()
if len(requirement_assessment.requirement.reference_controls.all()) > 0:
assert requirement_assessment.applied_controls.all() is not None
assert len(requirement_assessment.applied_controls.all()) > 0
for control in requirement_assessment.applied_controls.all():
assert (
control.reference_control
in requirement_assessment.requirement.reference_controls.all()
)

if len(requirement_assessment.requirement.reference_controls.all()) == 0:
assert requirement_assessment.applied_controls.all().count() == 0
return

assert requirement_assessment.applied_controls.all() is not None
assert len(requirement_assessment.applied_controls.all()) > 0
for control in requirement_assessment.applied_controls.all():
assert (
control.reference_control
in requirement_assessment.requirement.reference_controls.all()
)

# NOTE: running create_applied_controls_from_suggestions agani MUST not create
# any new applied control.

applied_controls_count: int = (
requirement_assessment.applied_controls.all().count()
)
requirement_assessment.create_applied_controls_from_suggestions()
assert (
requirement_assessment.applied_controls.all().count()
== applied_controls_count
)

0 comments on commit 97e7c72

Please sign in to comment.