diff --git a/h/presenters/group_json.py b/h/presenters/group_json.py index c39db77d1f9..8fa635fbb6f 100644 --- a/h/presenters/group_json.py +++ b/h/presenters/group_json.py @@ -22,6 +22,7 @@ def asdict(self, expand=None): # DEPRECATED: TODO: remove from client "scoped": bool(self.group.scopes), "type": self.group.type, + "pre_moderated": self.group.pre_moderated, } if expand: diff --git a/h/schemas/api/group.py b/h/schemas/api/group.py index b076130b5f9..d877f1ff4bf 100644 --- a/h/schemas/api/group.py +++ b/h/schemas/api/group.py @@ -18,6 +18,7 @@ "description": {"type": "string", "maxLength": GROUP_DESCRIPTION_MAX_LENGTH}, "groupid": {"type": "string", "pattern": GROUPID_PATTERN}, "type": {"enum": ["private", "restricted", "open"]}, + "pre_moderated": {"type": "boolean"}, } diff --git a/tests/unit/h/presenters/group_json_test.py b/tests/unit/h/presenters/group_json_test.py index 98d83130f04..5c885e77c68 100644 --- a/tests/unit/h/presenters/group_json_test.py +++ b/tests/unit/h/presenters/group_json_test.py @@ -13,24 +13,29 @@ @pytest.mark.usefixtures("group_links_service") class TestGroupJSONPresenter: - def test_it(self, factories, pyramid_request, group_links_service): + @pytest.mark.parametrize("pre_moderated", (True, False)) + def test_it(self, factories, pyramid_request, group_links_service, pre_moderated): group = factories.Group( name="My Group", pubid="mygroup", authority_provided_id="abc123", organization=factories.Organization(), + pre_moderated=pre_moderated, ) results = GroupJSONPresenter(group, pyramid_request).asdict() assert results == Any.dict.containing( { - "name": "My Group", "id": "mygroup", + "links": group_links_service.get_all.return_value, "groupid": "group:abc123@example.com", + "name": "My Group", "organization": group.organization.pubid, - "links": group_links_service.get_all.return_value, + "public": group.is_public, "scoped": False, + "type": group.type, + "pre_moderated": pre_moderated, } ) diff --git a/tests/unit/h/views/api/groups_test.py b/tests/unit/h/views/api/groups_test.py index 4f8b02fca44..40c51b78258 100644 --- a/tests/unit/h/views/api/groups_test.py +++ b/tests/unit/h/views/api/groups_test.py @@ -337,6 +337,7 @@ def test_it_when_request_json_body_is_invalid( type="private", ), ), + ({"pre_moderated": True}, call.update(sentinel.group, pre_moderated=True)), ], ) def test_update(