Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilouf committed Jan 10, 2025
1 parent bd1dc51 commit fad3fe9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lemarche/templates/admin/anonymize_confirmation.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h2>Utilisateurs à anonymiser</h2>
<input type="submit" value="{% translate 'Yes, I’m sure' %}">
<a href="#" class="button cancel-link">{% translate "No, take me back" %}</a>
</div>

</form>

{% endblock %}
1 change: 1 addition & 0 deletions lemarche/users/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def anonymize_users_view(self, request):
"queryset": queryset,
}
return TemplateResponse(request, "admin/anonymize_confirmation.html", context)

if request.method == "POST":
# anonymize users
ids = request.POST.getlist("user_id")
Expand Down
10 changes: 8 additions & 2 deletions lemarche/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,15 @@ def test_anonymize_action(self):
response = self.client.post(path=change_url, data=data)

self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, change_url)

data_confirm = {"user_id": users_ids}

# click on confirm after seeing the confirmation page
response_confirm = self.client.post(response.url, data=data_confirm)
self.assertEqual(response.status_code, 302)

self.assertTrue(User.objects.filter(is_staff=False).first().is_anonymized)
self.assertFalse(User.objects.filter(is_staff=True).first().is_anonymized)

messages_strings = [str(message) for message in get_messages(response.wsgi_request)]
messages_strings = [str(message) for message in get_messages(response_confirm.wsgi_request)]
self.assertIn("L'anonymisation s'est déroulée avec succès", messages_strings)

0 comments on commit fad3fe9

Please sign in to comment.