summaryrefslogtreecommitdiff
path: root/src/mailman/rest
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/rest')
-rw-r--r--src/mailman/rest/docs/lists.rst11
-rw-r--r--src/mailman/rest/lists.py5
-rw-r--r--src/mailman/rest/tests/test_lists.py21
3 files changed, 31 insertions, 6 deletions
diff --git a/src/mailman/rest/docs/lists.rst b/src/mailman/rest/docs/lists.rst
index 6a034df94..67cbb697a 100644
--- a/src/mailman/rest/docs/lists.rst
+++ b/src/mailman/rest/docs/lists.rst
@@ -191,10 +191,13 @@ Apply a style at list creation time
of a particular type, e.g. discussion lists. We can see which styles are
available, and which is the default style.
- >>> dump_json('http://localhost:9001/3.0/lists/styles')
- default: legacy-default
- http_etag: "..."
- style_names: ['legacy-announce', 'legacy-default']
+ >>> json = call_http('http://localhost:9001/3.0/lists/styles')
+ >>> json['default']
+ 'legacy-default'
+ >>> for style in json['styles']:
+ ... print('{}: {}'.format(style['name'], style['description']))
+ legacy-announce: Announce only mailing list style.
+ legacy-default: Ordinary discussion mailing list style.
When creating a list, if we don't specify a style to apply, the default style
is used. However, we can provide a style name in the POST data to choose a
diff --git a/src/mailman/rest/lists.py b/src/mailman/rest/lists.py
index 4b467afb3..482d3e2d7 100644
--- a/src/mailman/rest/lists.py
+++ b/src/mailman/rest/lists.py
@@ -414,9 +414,10 @@ class Styles:
def __init__(self):
manager = getUtility(IStyleManager)
- style_names = sorted(style.name for style in manager.styles)
+ styles = [dict(name=style.name, description=style.description)
+ for style in manager.styles]
self._resource = dict(
- style_names=style_names,
+ styles=styles,
default=config.styles.default)
def on_get(self, request, response):
diff --git a/src/mailman/rest/tests/test_lists.py b/src/mailman/rest/tests/test_lists.py
index 0f3b99393..44446b289 100644
--- a/src/mailman/rest/tests/test_lists.py
+++ b/src/mailman/rest/tests/test_lists.py
@@ -347,6 +347,27 @@ class TestLists(unittest.TestCase):
self.assertEqual(cm.exception.reason, 'Missing parameters: emails')
+class TestListStyles(unittest.TestCase):
+ """Test /lists/styles."""
+
+ layer = RESTLayer
+
+ def test_styles(self):
+ json, response = call_api('http://localhost:9001/3.0/lists/styles')
+ self.assertEqual(response.status_code, 200)
+ # Remove the variable data.
+ json.pop('http_etag')
+ self.assertEqual(json, {
+ 'styles': [
+ {'name': 'legacy-announce',
+ 'description': 'Announce only mailing list style.'},
+ {'name': 'legacy-default',
+ 'description': 'Ordinary discussion mailing list style.'}
+ ],
+ 'default': 'legacy-default'
+ })
+
+
class TestListArchivers(unittest.TestCase):
"""Test corner cases for list archivers."""