-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feature/empower-haie-…
…admin
- Loading branch information
Showing
61 changed files
with
1,341 additions
and
646 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,9 @@ def moulinette_url(footprint): | |
return f"https://envergo.beta.gouv.fr?{url}" | ||
|
||
|
||
def fake_moulinette(url, lse, n2000, evalenv, sage, **eval_kwargs): | ||
def fake_moulinette( | ||
url, lse, n2000, evalenv, sage, sage_results_by_perimeter=None, **eval_kwargs | ||
): | ||
"""Create a moulinette with custom regulation results.""" | ||
|
||
eval_params = { | ||
|
@@ -79,6 +81,7 @@ def fake_moulinette(url, lse, n2000, evalenv, sage, **eval_kwargs): | |
|
||
# We create mocks based on a real regulation, so it's easier to fake results | ||
regulation = RegulationFactory() | ||
sage_perimeter = Mock(contact_email="[email protected]") | ||
moulinette.regulations = [ | ||
Mock( | ||
regulation, | ||
|
@@ -105,11 +108,14 @@ def fake_moulinette(url, lse, n2000, evalenv, sage, **eval_kwargs): | |
regulation, | ||
wraps=regulation, | ||
result=sage, | ||
perimeters=Mock( | ||
all=MagicMock(return_value=[Mock(contact_email="[email protected]")]) | ||
), | ||
perimeters=Mock(all=MagicMock(return_value=[sage_perimeter])), | ||
slug="sage", | ||
do_not_call_in_templates=True, | ||
results_by_perimeter=( | ||
sage_results_by_perimeter | ||
if sage_results_by_perimeter | ||
else {sage_perimeter: sage} | ||
), | ||
), | ||
] | ||
|
||
|
@@ -650,3 +656,47 @@ def test_n2000_ein_out_of_n2000_site_no_bcc(rf, moulinette_url): | |
eval_email = eval.get_evaluation_email() | ||
email = eval_email.get_email(req) | ||
assert "[email protected]" not in email.bcc | ||
|
||
|
||
@pytest.mark.parametrize("footprint", [1200]) | ||
def test_multiple_sage(rf, moulinette_url): | ||
"""Test email when evalreq is: | ||
- created by an instructor | ||
- the eval result is "soumis" | ||
- there is multiple Sage perimeter impacted with different results | ||
""" | ||
eval_kwargs = { | ||
"user_type": USER_TYPES.instructor, | ||
"moulinette_url": moulinette_url, | ||
"send_eval_to_project_owner": True, | ||
} | ||
eval, moulinette = fake_moulinette( | ||
moulinette_url, | ||
"soumis", | ||
"soumis", | ||
"systematique", | ||
"soumis", | ||
sage_results_by_perimeter={ | ||
Mock(contact_email="[email protected]"): "interdit", | ||
Mock(contact_email="[email protected]"): "action_requise", | ||
Mock(contact_email="[email protected]"): "non_disponible", | ||
}, | ||
**eval_kwargs, | ||
) | ||
|
||
req = rf.get("/") | ||
eval_email = eval.get_evaluation_email() | ||
email = eval_email.get_email(req) | ||
assert email.to == ["[email protected]", "[email protected]"] | ||
assert email.cc == ["[email protected]"] | ||
|
||
assert email.bcc == [ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
|
||
body = email.body | ||
assert "À transmettre au porteur" not in body |
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
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
Oops, something went wrong.