forked from inveniosoftware/invenio-communities
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
membership-request [inveniosoftware#855]: address TODOs
- Loading branch information
Showing
11 changed files
with
77 additions
and
51 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 |
---|---|---|
|
@@ -238,6 +238,10 @@ def test_search( | |
assert r.status_code == 200 | ||
data = r.json | ||
assert data["sortBy"] == "name" | ||
expected_links = { | ||
"self": f"https://127.0.0.1:5000/api/communities/{community_id}/members?page=1&size=25&sort=name" # noqa | ||
} | ||
assert expected_links == data["links"] | ||
assert data["hits"]["total"] == 3 | ||
assert "role" in data["aggregations"] | ||
assert "visibility" in data["aggregations"] | ||
|
@@ -300,6 +304,10 @@ def test_search_public( | |
assert r.status_code == 200 | ||
data = r.json | ||
assert data["sortBy"] == "name" | ||
expected_links = { | ||
"self": f"https://127.0.0.1:5000/api/communities/{community_id}/members?page=1&size=25&sort=name" # noqa | ||
} | ||
assert expected_links == data["links"] | ||
assert data["hits"]["total"] == 1 | ||
hit = data["hits"]["hits"][0] | ||
# Public view has no facets (because that would leak information on | ||
|
@@ -350,9 +358,15 @@ def test_search_invitation( | |
assert hit["permissions"]["can_update_role"] is True | ||
assert hit["permissions"]["can_cancel"] is True | ||
|
||
request_id = hit["request"]["id"] | ||
expected_links = { | ||
"actions": { | ||
"cancel": f"https://127.0.0.1:5000/api/requests/{request_id}/actions/cancel", | ||
}, | ||
} | ||
assert expected_links == hit["links"] | ||
|
||
|
||
# TODO: member serialization/links | ||
# TODO: request serialization/links | ||
# TODO: community member can see info | ||
# TODO: community non-member can't see info | ||
# TODO: facet by role, facet by visibility, define sorts. | ||
|
@@ -375,9 +389,8 @@ def test_post_membership_requests(app, client, headers, community_id, create_use | |
headers=headers, | ||
json={"message": "Can I join the club?"}, | ||
) | ||
assert 201 == r.status_code | ||
|
||
RequestEvent.index.refresh() | ||
assert 201 == r.status_code | ||
|
||
# Get links to check | ||
url_of_request = r.json["links"]["self"].replace(app.config["SITE_API_URL"], "") | ||
|
@@ -399,22 +412,25 @@ def test_post_membership_requests(app, client, headers, community_id, create_use | |
assert "Can I join the club?" == msg | ||
|
||
|
||
def test_put_membership_requests( | ||
client, headers, community_id, owner, new_user_data, db | ||
): | ||
# update membership request | ||
# TODO: Implement me! | ||
assert True | ||
|
||
|
||
def test_error_handling_for_membership_requests( | ||
client, headers, community_id, owner, new_user_data, db | ||
client, create_user, headers, community_id, owner, new_user_data, db | ||
): | ||
# TODO: Implement me! | ||
# error handling registered | ||
# - permission handling registered | ||
# - duplicate handling registered | ||
assert True | ||
user = create_user({"email": "[email protected]", "username": "user_foo"}) | ||
client = user.login(client) | ||
r = client.post( | ||
f"/communities/{community_id}/membership-requests", | ||
headers=headers, | ||
json={"message": "Can I join the club?"}, | ||
) | ||
assert 201 == r.status_code | ||
|
||
# Error if duplicate posting | ||
r = client.post( | ||
f"/communities/{community_id}/membership-requests", | ||
headers=headers, | ||
json={"message": "Can I join the club again?"}, | ||
) | ||
assert 400 == r.status_code | ||
|
||
|
||
def test_get_membership_requests( | ||
|
@@ -451,6 +467,7 @@ def test_get_membership_requests( | |
assert "id" in hit["request"] | ||
assert "status" in hit["request"] | ||
assert "expires_at" in hit["request"] | ||
# hits > hit > links | ||
request_id = hit["request"]["id"] | ||
expected_links = { | ||
"actions": { | ||
|
@@ -459,11 +476,8 @@ def test_get_membership_requests( | |
}, | ||
} | ||
assert expected_links == hit["links"] | ||
# hits > hit > permissions | ||
assert hit["permissions"]["can_update_role"] is True | ||
|
||
# TODO: Expiration flow : assess if expiration makes sense for membership requests. | ||
# assert hit["request"]["expires_at"] is not None | ||
# TODO: Decision flow | ||
# hits > hit > permissions | ||
# assert "permissions" in hit | ||
# assert hit["permissions"]["can_update_role"] is True | ||
# assert hit["permissions"]["can_cancel"] is True | ||
# hits > hit > links |