summaryrefslogtreecommitdiff
path: root/src/mailman/rest
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/rest')
-rw-r--r--src/mailman/rest/docs/membership.rst13
-rw-r--r--src/mailman/rest/docs/moderation.rst25
-rw-r--r--src/mailman/rest/tests/test_moderation.py11
3 files changed, 32 insertions, 17 deletions
diff --git a/src/mailman/rest/docs/membership.rst b/src/mailman/rest/docs/membership.rst
index 0343f40a1..3cb83a0c8 100644
--- a/src/mailman/rest/docs/membership.rst
+++ b/src/mailman/rest/docs/membership.rst
@@ -39,6 +39,9 @@ the REST interface.
>>> from mailman.testing.helpers import subscribe
>>> subscribe(bee, 'Bart')
+ <Member: Bart Person <bperson@example.com> on bee@example.com
+ as MemberRole.member>
+
>>> dump_json('http://localhost:9001/3.0/members')
entry 0:
address: http://localhost:9001/3.0/addresses/bperson@example.com
@@ -69,8 +72,12 @@ Bart's specific membership can be accessed directly:
When Cris also joins the mailing list, her subscription is also available via
the REST interface.
+::
>>> subscribe(bee, 'Cris')
+ <Member: Cris Person <cperson@example.com> on bee@example.com
+ as MemberRole.member>
+
>>> dump_json('http://localhost:9001/3.0/members')
entry 0:
address: http://localhost:9001/3.0/addresses/bperson@example.com
@@ -101,6 +108,8 @@ subscribes, she is returned first.
::
>>> subscribe(bee, 'Anna')
+ <Member: Anna Person <aperson@example.com> on bee@example.com
+ as MemberRole.member>
>>> dump_json('http://localhost:9001/3.0/members')
entry 0:
@@ -143,7 +152,11 @@ address. Anna and Cris subscribe to this new mailing list.
>>> ant = create_list('ant@example.com')
>>> subscribe(ant, 'Anna')
+ <Member: Anna Person <aperson@example.com> on ant@example.com
+ as MemberRole.member>
>>> subscribe(ant, 'Cris')
+ <Member: Cris Person <cperson@example.com> on ant@example.com
+ as MemberRole.member>
User ids are different than member ids.
diff --git a/src/mailman/rest/docs/moderation.rst b/src/mailman/rest/docs/moderation.rst
index 6aec921f0..0a9fd59a8 100644
--- a/src/mailman/rest/docs/moderation.rst
+++ b/src/mailman/rest/docs/moderation.rst
@@ -216,24 +216,26 @@ requests.
When Anne tries to subscribe to the Ant list, her subscription is held for
moderator approval.
+::
>>> from mailman.app.moderator import hold_subscription
>>> from mailman.interfaces.member import DeliveryMode
+ >>> from mailman.interfaces.subscriptions import RequestRecord
+
>>> sub_req_id = hold_subscription(
- ... ant, 'anne@example.com', 'Anne Person',
- ... 'password', DeliveryMode.regular, 'en')
+ ... ant, RequestRecord('anne@example.com', 'Anne Person',
+ ... DeliveryMode.regular, 'en'))
>>> transaction.commit()
The subscription request is available from the mailing list.
>>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/requests')
entry 0:
- address: anne@example.com
delivery_mode: regular
display_name: Anne Person
+ email: anne@example.com
http_etag: "..."
language: en
- password: password
request_id: ...
type: subscription
when: 2005-08-01T07:49:23
@@ -247,10 +249,9 @@ Viewing unsubscription requests
Bart tries to leave a mailing list, but he may not be allowed to.
- >>> from mailman.app.membership import add_member
+ >>> from mailman.testing.helpers import subscribe
>>> from mailman.app.moderator import hold_unsubscription
- >>> bart = add_member(ant, 'bart@example.com', 'Bart Person',
- ... 'password', DeliveryMode.regular, 'en')
+ >>> bart = subscribe(ant, 'Bart', email='bart@example.com')
>>> unsub_req_id = hold_unsubscription(ant, 'bart@example.com')
>>> transaction.commit()
@@ -258,17 +259,16 @@ The unsubscription request is also available from the mailing list.
>>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/requests')
entry 0:
- address: anne@example.com
delivery_mode: regular
display_name: Anne Person
+ email: anne@example.com
http_etag: "..."
language: en
- password: password
request_id: ...
type: subscription
when: 2005-08-01T07:49:23
entry 1:
- address: bart@example.com
+ email: bart@example.com
http_etag: "..."
request_id: ...
type: unsubscription
@@ -285,12 +285,11 @@ request id. Anne's subscription request looks like this.
>>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/'
... 'requests/{}'.format(sub_req_id))
- address: anne@example.com
delivery_mode: regular
display_name: Anne Person
+ email: anne@example.com
http_etag: "..."
language: en
- password: password
request_id: ...
type: subscription
when: 2005-08-01T07:49:23
@@ -299,7 +298,7 @@ Bart's unsubscription request looks like this.
>>> dump_json('http://localhost:9001/3.0/lists/ant@example.com/'
... 'requests/{}'.format(unsub_req_id))
- address: bart@example.com
+ email: bart@example.com
http_etag: "..."
request_id: ...
type: unsubscription
diff --git a/src/mailman/rest/tests/test_moderation.py b/src/mailman/rest/tests/test_moderation.py
index 262a7ec60..c77ae2aca 100644
--- a/src/mailman/rest/tests/test_moderation.py
+++ b/src/mailman/rest/tests/test_moderation.py
@@ -29,6 +29,7 @@ from mailman.app.moderator import hold_message, hold_subscription
from mailman.config import config
from mailman.database.transaction import transaction
from mailman.interfaces.member import DeliveryMode
+from mailman.interfaces.subscriptions import RequestRecord
from mailman.testing.helpers import (
call_api, specialized_message_from_string as mfs)
from mailman.testing.layers import RESTLayer
@@ -76,8 +77,9 @@ Something else.
# in the database.
held_id = hold_message(self._mlist, self._msg)
subscribe_id = hold_subscription(
- self._mlist, 'bperson@example.net', 'Bart Person', 'xyz',
- DeliveryMode.regular, 'en')
+ self._mlist,
+ RequestRecord('bperson@example.net', 'Bart Person',
+ DeliveryMode.regular, 'en'))
config.db.store.commit()
url = 'http://localhost:9001/3.0/lists/ant@example.com/held/{0}'
with self.assertRaises(HTTPError) as cm:
@@ -114,8 +116,9 @@ Something else.
def test_bad_subscription_action(self):
# POSTing to a held message with a bad action.
held_id = hold_subscription(
- self._mlist, 'cperson@example.net', 'Cris Person', 'xyz',
- DeliveryMode.regular, 'en')
+ self._mlist,
+ RequestRecord('cperson@example.net', 'Cris Person',
+ DeliveryMode.regular, 'en'))
config.db.store.commit()
url = 'http://localhost:9001/3.0/lists/ant@example.com/requests/{0}'
with self.assertRaises(HTTPError) as cm: