# Path: invenio_communities/communities/records/api.py
# class Community(Record):
#     """Community API."""
# 
#     pid = PIDField('id', provider=CommunitiesIdProvider, create=False)
#     schema = ConstantField(
#         '$schema', 'local://communities/communities-v1.0.0.json')
# 
#     model_cls = models.CommunityMetadata
# 
#     index = IndexField(
#         "communities-communities-v1.0.0",
#         search_alias="communities"
#     )
# 
#     access = CommunityAccessField()
# 
#     bucket_id = ModelField(dump=False)
#     bucket = ModelField(dump=False)
#     files = FilesField(
#         store=False,
#         file_cls=CommunityFile,
#         # Don't delete, we'll manage in the service
#         delete=False,
#     )


import copy
from io import BytesIO
from invenio_communities.communities.records.api import Community
                          ]
    error_messages = set([item['messages'][0] for item in response.json['errors']])

    assert expected == len(set(error_messages_list).intersection(error_messages))


def test_simple_flow(
    app, client_with_login, location, minimal_community, headers,
    es_clear
):
    """Test a simple REST API flow."""
    client = client_with_login
    # Create a community
    res = client.post(
        '/communities', headers=headers,
        json=minimal_community)
    assert res.status_code == 201
    _assert_single_item_response(res)

    created_community = res.json
    id_ = created_community["id"]

    # Read the community
    res = client.get(f'/communities/{id_}', headers=headers)
    assert res.status_code == 200
    assert res.json['metadata'] == \
        created_community['metadata']

    read_community = res.json


# Path: invenio_communities/communities/records/api.py
# class Community(Record):
#     """Community API."""
# 
#     pid = PIDField('id', provider=CommunitiesIdProvider, create=False)
#     schema = ConstantField(
#         '$schema', 'local://communities/communities-v1.0.0.json')
# 
#     model_cls = models.CommunityMetadata
# 
#     index = IndexField(
#         "communities-communities-v1.0.0",
#         search_alias="communities"
#     )
# 
#     access = CommunityAccessField()
# 
#     bucket_id = ModelField(dump=False)
#     bucket = ModelField(dump=False)
#     files = FilesField(
#         store=False,
#         file_cls=CommunityFile,
#         # Don't delete, we'll manage in the service
#         delete=False,
#     )


# Path: tests/communities/test_resources.py
import copy
from io import BytesIO
from invenio_communities.communities.records.api import Community

                          ]
    error_messages = set([item['messages'][0] for item in response.json['errors']])

    assert expected == len(set(error_messages_list).intersection(error_messages))


def test_simple_flow(
    app, client_with_login, location, minimal_community, headers,
    es_clear
):
    """Test a simple REST API flow."""
    client = client_with_login
    # Create a community
    res = client.post(
        '/communities', headers=headers,
        json=minimal_community)
    assert res.status_code == 201
    _assert_single_item_response(res)

    created_community = res.json
    id_ = created_community["id"]

    # Read the community
    res = client.get(f'/communities/{id_}', headers=headers)
    assert res.status_code == 200
    assert res.json['metadata'] == \
        created_community['metadata']

    read_community = res.json


    Community.index.refresh()