-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
records: add status field to community records
* added "status" field to community records * renamed "is_verified" property to "is_safelisted" * updated mappings to support "is_safelisted" * added tests for the new field * added tests for safelisting feature
- Loading branch information
1 parent
df0ca54
commit 65da818
Showing
13 changed files
with
151 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2024 CERN. | ||
# | ||
# Invenio-communities is free software; you can redistribute it and/or modify | ||
# it under the terms of the MIT License; see LICENSE file for more details. | ||
"""Test safelist feature for communities.""" | ||
|
||
from copy import deepcopy | ||
|
||
from invenio_db import db | ||
|
||
from invenio_communities.communities.records.models import CommunityStatusEnum | ||
|
||
|
||
def test_safelist_computed_by_verified_status( | ||
community_service, minimal_community, location, es_clear, unverified_user | ||
): | ||
""" | ||
Test that the safelist feature for communities is computed correctly based on the verified status. | ||
""" | ||
# Create a comunity | ||
# Flag it as "verified" | ||
# Validate that the computed field "is_verified" is set to "True" | ||
c_data = deepcopy(minimal_community) | ||
c_data["slug"] = "test_status_perms" | ||
c_item = community_service.create(unverified_user.identity, data=c_data) | ||
assert c_item._record.status == CommunityStatusEnum.NEW | ||
assert c_item._record.is_safelisted is False | ||
community = community_service.record_cls.pid.resolve(c_item.id) | ||
community.status = CommunityStatusEnum.VERIFIED | ||
community.commit() | ||
db.session.commit() | ||
c_item = community_service.read(unverified_user.identity, c_item.id) | ||
assert c_item._record.is_safelisted is True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters