-
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.
Merge pull request #10 from oarepo/krist/be-241-self-link-on-requests…
…-goes-to-the-extended-service-but-one nr docs release issues
- Loading branch information
Showing
14 changed files
with
271 additions
and
62 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
Empty file.
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,29 @@ | ||
from flask_resources import ResponseHandler | ||
from invenio_records_resources.services.base.config import ConfiguratorMixin | ||
from invenio_requests.resources.events.config import RequestCommentsResourceConfig | ||
|
||
from oarepo_requests.resources.ui import OARepoRequestsUIJSONSerializer | ||
|
||
|
||
class OARepoRequestsCommentsResourceConfig( | ||
RequestCommentsResourceConfig, ConfiguratorMixin | ||
): | ||
"""""" | ||
|
||
blueprint_name = "oarepo_request_events" | ||
url_prefix = "/requests" | ||
routes = { | ||
**RequestCommentsResourceConfig.routes, | ||
"list-extended": "/extended/<request_id>/comments", | ||
"item-extended": "/extended/<request_id>/comments/<comment_id>", | ||
"timeline-extended": "/extended/<request_id>/timeline", | ||
} | ||
|
||
@property | ||
def response_handlers(self): | ||
return { | ||
"application/vnd.inveniordm.v1+json": ResponseHandler( | ||
OARepoRequestsUIJSONSerializer() | ||
), | ||
**super().response_handlers, | ||
} |
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,36 @@ | ||
from flask_resources import route | ||
from invenio_records_resources.resources.errors import ErrorHandlersMixin | ||
from invenio_requests.resources.events.resource import RequestCommentsResource | ||
|
||
|
||
class OARepoRequestsCommentsResource(RequestCommentsResource, ErrorHandlersMixin): | ||
|
||
def create_url_rules(self): | ||
"""Create the URL rules for the record resource.""" | ||
base_routes = super().create_url_rules() | ||
routes = self.config.routes | ||
|
||
url_rules = [ | ||
route("POST", routes["list-extended"], self.create_extended), | ||
route("GET", routes["item-extended"], self.read_extended), | ||
route("PUT", routes["item-extended"], self.update_extended), | ||
route("DELETE", routes["item-extended"], self.delete_extended), | ||
route("GET", routes["timeline-extended"], self.search_extended), | ||
] | ||
return url_rules + base_routes | ||
|
||
# from parent | ||
def create_extended(self): | ||
return super().create() | ||
|
||
def read_extended(self): | ||
return super().read() | ||
|
||
def update_extended(self): | ||
return super().update() | ||
|
||
def delete_extended(self): | ||
return super().delete() | ||
|
||
def search_extended(self): | ||
return super().search() |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[metadata] | ||
name = oarepo-requests | ||
version = 1.1.4 | ||
version = 1.1.5 | ||
description = | ||
authors = Ronald Krist <[email protected]> | ||
readme = README.md | ||
|
@@ -31,14 +31,14 @@ invenio_base.api_apps = | |
oarepo_requests = oarepo_requests.ext:OARepoRequests | ||
invenio_base.apps = | ||
thesis = oarepo_requests.ext:OARepoRequests | ||
#invenio_base.blueprints = | ||
# oarepo_requests = oarepo_requests.views.api:create_oarepo_requests | ||
|
||
invenio_base.api_blueprints = | ||
oarepo_requests = oarepo_requests.views.api:create_oarepo_requests | ||
oarepo_requests_events = oarepo_requests.views.api:create_oarepo_requests_events | ||
|
||
invenio_base.blueprints = | ||
oarepo_requests = oarepo_requests.views.app:create_app_blueprint | ||
oarepo_requests_events = oarepo_requests.views.app:create_app_events_blueprint | ||
|
||
|
||
|
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,142 @@ | ||
from invenio_requests.records.api import RequestEvent | ||
|
||
from .utils import is_valid_subdict, link_api2testclient | ||
|
||
|
||
def test_read_extended( | ||
example_topic_draft, | ||
client_logged_as, | ||
users, | ||
urls, | ||
publish_request_data_function, | ||
serialization_result, | ||
ui_serialization_result, | ||
search_clear, | ||
): | ||
receiver = users[1] | ||
creator_client = client_logged_as(users[0].email) | ||
resp_request_create = creator_client.post( | ||
urls["BASE_URL_REQUESTS"], | ||
json=publish_request_data_function(example_topic_draft["id"]), | ||
) | ||
resp_request_submit = creator_client.post( | ||
link_api2testclient(resp_request_create.json["links"]["actions"]["submit"]) | ||
) | ||
receiver_client = client_logged_as(users[1].email) | ||
old_call = receiver_client.get( | ||
f"{urls['BASE_URL_REQUESTS']}{resp_request_create.json['id']}" | ||
) | ||
new_call = receiver_client.get( | ||
f"{urls['BASE_URL_REQUESTS']}extended/{resp_request_create.json['id']}" | ||
) | ||
new_call2 = receiver_client.get( | ||
f"{urls['BASE_URL_REQUESTS']}extended/{resp_request_create.json['id']}", | ||
headers={"Accept": "application/vnd.inveniordm.v1+json"}, | ||
) | ||
|
||
assert is_valid_subdict( | ||
serialization_result(example_topic_draft["id"], resp_request_create.json["id"]), | ||
new_call.json, | ||
) | ||
assert is_valid_subdict( | ||
ui_serialization_result( | ||
example_topic_draft["id"], resp_request_create.json["id"] | ||
), | ||
new_call2.json, | ||
) | ||
|
||
|
||
def test_update_self_link( | ||
example_topic_draft, | ||
client_logged_as, | ||
users, | ||
urls, | ||
publish_request_data_function, | ||
serialization_result, | ||
ui_serialization_result, | ||
search_clear, | ||
): | ||
receiver = users[1] | ||
creator_client = client_logged_as(users[0].email) | ||
resp_request_create = creator_client.post( | ||
urls["BASE_URL_REQUESTS"], | ||
json=publish_request_data_function(example_topic_draft["id"]), | ||
) | ||
resp_request_submit = creator_client.post( | ||
link_api2testclient(resp_request_create.json["links"]["actions"]["submit"]) | ||
) | ||
read_before = creator_client.get( | ||
link_api2testclient(resp_request_submit.json["links"]["self"]), | ||
) | ||
read_from_record = creator_client.get( | ||
f"{urls['BASE_URL']}{example_topic_draft['id']}/draft", | ||
) | ||
link_to_extended = link_api2testclient( | ||
read_from_record.json["requests"][0]["links"]["self"] | ||
) | ||
|
||
assert link_to_extended.startswith(f"{urls['BASE_URL_REQUESTS']}extended") | ||
update_extended = creator_client.put( | ||
link_to_extended, | ||
json={"title": "lalala"}, | ||
) | ||
assert update_extended.status_code == 200 | ||
read_after = creator_client.get( | ||
link_api2testclient(resp_request_submit.json["links"]["self"]), | ||
) | ||
assert read_before.json["title"] == "" | ||
assert read_after.json["title"] == "lalala" | ||
|
||
|
||
def test_events_resource( | ||
example_topic_draft, | ||
client_logged_as, | ||
users, | ||
urls, | ||
publish_request_data_function, | ||
serialization_result, | ||
ui_serialization_result, | ||
events_resource_data, | ||
search_clear, | ||
): | ||
creator_client = client_logged_as(users[0].email) | ||
resp_request_create = creator_client.post( | ||
urls["BASE_URL_REQUESTS"], | ||
json=publish_request_data_function(example_topic_draft["id"]), | ||
) | ||
resp_request_submit = creator_client.post( | ||
link_api2testclient(resp_request_create.json["links"]["actions"]["submit"]) | ||
) | ||
read_before = creator_client.get( | ||
link_api2testclient(resp_request_submit.json["links"]["self"]), | ||
headers={"Accept": "application/vnd.inveniordm.v1+json"}, | ||
) | ||
read_from_record = creator_client.get( | ||
f"{urls['BASE_URL']}{example_topic_draft['id']}/draft", | ||
) | ||
|
||
comments_link = link_api2testclient( | ||
read_from_record.json["requests"][0]["links"]["comments"] | ||
) | ||
timeline_link = link_api2testclient( | ||
read_from_record.json["requests"][0]["links"]["timeline"] | ||
) | ||
|
||
assert comments_link.startswith("/requests/extended") | ||
assert timeline_link.startswith("/requests/extended") | ||
|
||
comments_extended = creator_client.post( | ||
comments_link, | ||
json=events_resource_data, | ||
) | ||
assert comments_extended.status_code == 201 | ||
comment = creator_client.get( | ||
f"{comments_link}/{comments_extended.json['id']}", | ||
) | ||
assert comment.status_code == 200 | ||
RequestEvent.index.refresh() | ||
comments_extended_timeline = creator_client.get( | ||
timeline_link, | ||
) | ||
assert comments_extended_timeline.status_code == 200 | ||
assert len(comments_extended_timeline.json["hits"]["hits"]) == 1 |
Oops, something went wrong.