Bug #40733
python3: Impossible d'ajouter un rôle
Statut:
Fermé
Priorité:
Normal
Assigné à:
-
Catégorie:
-
Version cible:
-
Début:
13 mars 2020
Echéance:
% réalisé:
0%
Temps estimé:
Patch proposed:
Oui
Planning:
Non
Description
Message ajax : 'Dialog box loading failed: error Internal Server Error
'
et trace :
File "/home/nroche/src/authentic/src/authentic2/manager/views.py", line 144, in dispatch return super(PermissionMixin, self).dispatch(request, *args, **kwargs) File "/home/nroche/src/authentic/src/authentic2/manager/views.py", line 266, in dispatch return self.return_ajax_response(request, response) File "/home/nroche/src/authentic/src/authentic2/manager/views.py", line 286, in return_ajax_response return HttpResponse(json.dumps(data), content_type='application/json') File "/usr/lib/python3.7/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/usr/lib/python3.7/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib/python3.7/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/usr/lib/python3.7/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type bytes is not JSON serializable
Fichiers
Demandes liées
Révisions associées
Historique
Mis à jour par Nicolas Roche il y a environ 4 ans
- Fichier 0001-python3-build-ajax-response-using-text-content-40733.patch 0001-python3-build-ajax-response-using-text-content-40733.patch ajouté
- Statut changé de Nouveau à Solution proposée
- Patch proposed changé de Non à Oui
Je proposerai bien cette correction, mais je ne sais pas comment écrire le test adéquat.
J'ai essayé sans succès de passer derrière 'if not request.is_ajax():
', comme par exemple avec :
def test_manager_create_role_using_ajax(superuser_or_admin, app): ou_add = login(app, superuser_or_admin, reverse('a2-manager-role-add')) ou_add.post('/manage/roles/add/', xhr=True)
Mis à jour par Nicolas Roche il y a environ 4 ans
- Lié à Development #40403: Tourner authentic2 en python3 ajouté
Mis à jour par Nicolas Roche il y a environ 4 ans
- Statut changé de Solution proposée à Information nécessaire
Je couvre le code avec ce test ; il faut à présent qu'il teste quelque-chose.
def test_manager_create_role_using_ajax(superuser_or_admin, app): app.set_user(superuser_or_admin.username) resp = app.get('/manage/roles/add/', xhr=True)
Je peux partir la dessus ?
Mis à jour par Nicolas Roche il y a environ 4 ans
- Fichier 0001-python3-build-ajax-response-using-text-content-40733.patch 0001-python3-build-ajax-response-using-text-content-40733.patch ajouté
- Statut changé de Information nécessaire à Solution proposée
bof, en fait je me dis qu'il n'y a de particulier à tester concernant ce patch.
Mis à jour par Benjamin Dauvergne il y a environ 4 ans
Le assert 'Authentic' n'est pas vraiment utile, tu peux juste vérifier que ['content']
est non vide, ça fera un test plus robuste.
Mis à jour par Benjamin Dauvergne il y a environ 4 ans
- Statut changé de Solution proposée à Solution validée
Mis à jour par Nicolas Roche il y a environ 4 ans
- Statut changé de Solution validée à Résolu (à déployer)
commit 5d8c2355be4e76c118d01166d114a44f84a36d76 Author: Nicolas ROCHE <nroche@entrouvert.com> Date: Fri Mar 13 23:55:08 2020 +0100 python3: build ajax response using text content (#40733)
Mis à jour par Frédéric Péters il y a environ 4 ans
- Statut changé de Résolu (à déployer) à Solution déployée
python3: build ajax response using text content (#40733)