preferences.save() returns an HTTP error 400 all the time

Bug #1172189 reported by Aurélien Bompard
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Mailman REST Client
Undecided
Unassigned

Bug Description

In the docs, it is written that preferences can be modified by calling the save() method, but there were no doctests for this and indeed it seems broken. I've added the following lines to using.txt:

=== modified file 'src/mailmanclient/docs/using.txt'
--- src/mailmanclient/docs/using.txt 2013-03-22 18:28:16 +0000
+++ src/mailmanclient/docs/using.txt 2013-04-24 08:43:49 +0000
@@ -522,6 +522,12 @@

 Preferences can be set, but you have to call ``save`` to make your changes permanent.

+ >>> prefs = test_two.get_member('<email address hidden>').preferences
+ >>> prefs['delivery_status'] = 'by_user'
+ >>> prefs.save()
+ >>> prefs = test_two.get_member('<email address hidden>').preferences
+ >>> print prefs['delivery_status']
+ by_user

 Owners and Moderators
 =====================

And I get these errors when running the test suite:

----------------------------------------------------------------------
File "/srv/dev/mailman/mailman.client/src/mailmanclient/docs/using.txt", line 527, in using.txt
Failed example:
    prefs.save()
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/doctest.py", line 1289, in __run
        compileflags, 1) in test.globs
      File "<doctest using.txt[152]>", line 1, in <module>
        prefs.save()
      File "/srv/dev/mailman/mailman.client/src/mailmanclient/_client.py", line 817, in save
        response, content = self._connection.call(self._url, data, 'PUT')
      File "/srv/dev/mailman/mailman.client/src/mailmanclient/_client.py", line 112, in call
        raise HTTPError(url, response.status, content, response, None)
    HTTPError: HTTP Error 400: Unexpected parameters: http_etag, self_link
----------------------------------------------------------------------
File "/srv/dev/mailman/mailman.client/src/mailmanclient/docs/using.txt", line 529, in using.txt
Failed example:
    print prefs['delivery_status']
Differences (ndiff with -expected +actual):
    - by_user
    + None
----------------------------------------------------------------------

It looks like the http_etag and self_link values should be filtered out of the preferences dictionary.
But when I do that in _client.py, I get another error:

----------------------------------------------------------------------
File "/srv/dev/mailman/mailman.client/src/mailmanclient/docs/using.txt", line 527, in using.txt
Failed example:
    prefs.save()
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib64/python2.7/doctest.py", line 1289, in __run
        compileflags, 1) in test.globs
      File "<doctest using.txt[152]>", line 1, in <module>
        prefs.save()
      File "/srv/dev/mailman/mailman.client/src/mailmanclient/_client.py", line 817, in save
        response, content = self._connection.call(self._url, data, 'PUT')
      File "/srv/dev/mailman/mailman.client/src/mailmanclient/_client.py", line 112, in call
        raise HTTPError(url, response.status, content, response, None)
    HTTPError: HTTP Error 400: Missing parameters: acknowledge_posts, receive_list_copy, receive_own_postings
----------------------------------------------------------------------

Apparently the PUT method requires all parameters to be sent, even when they are None. It works with the PATCH method however, using the attached patch. Could it be merged ?

Revision history for this message
Aurélien Bompard (abompard) wrote :
summary: - preferences.save() returns a 405 error all the time
+ preferences.save() returns an HTTP error 400 all the time
Revision history for this message
Florian Fuchs (flo-fuchs) wrote :

Hi Aurélien,

thanks for the patch! The bug itself had already been fixed a while ago, but I've added the doctests for that anyway since there were none yet.

Thanks again and sorry for the late reply...

Florian

Changed in mailman.client:
status: New → Fix Committed
Changed in mailman.client:
milestone: none → 1.0.0a1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers