Projet

Général

Profil

0001-api-do-not-clobber-HTTP-verb-methods-in-viewsets-509.patch

Benjamin Dauvergne, 05 février 2021 22:42

Télécharger (1,66 ko)

Voir les différences:

Subject: [PATCH] api: do not clobber HTTP verb methods in viewsets (#50919)

 src/authentic2/api_views.py | 6 +++---
 tests/test_api.py           | 5 +++++
 2 files changed, 8 insertions(+), 3 deletions(-)
src/authentic2/api_views.py
783 783
            return new_qs
784 784
        return qs
785 785

  
786
    # only do partial updates
787
    def put(self, request, *args, **kwargs):
788
        return self.patch(request, *args, **kwargs)
786
    def update(self, request, *args, **kwargs):
787
        kwargs['partial'] = True
788
        return super().update(request, *args, **kwargs)
789 789

  
790 790
    def check_perm(self, perm, ou):
791 791
        if ou:
tests/test_api.py
2225 2225
    headers = basic_authorization_header(admin)
2226 2226
    expected_status = 200 if drf_version > '3.9' else 404
2227 2227
    resp = app.get('/api/statistics/login/?time_interval=month', headers=headers, status=expected_status)
2228

  
2229

  
2230
def test_find_duplicates_put(app, admin, settings):
2231
    app.authorization = ('Basic', (admin.username, admin.username))
2232
    app.put_json('/api/users/find_duplicates/', params={'first_name': 'Eleonore', 'last_name': 'aeiou'}, status=405)
2228
-