Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Krist/tests refactor #105

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion oarepo_requests/actions/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
from functools import cached_property
from typing import TYPE_CHECKING, Any

from invenio_pidstore.errors import PersistentIdentifierError
from invenio_requests.customizations import actions
from oarepo_runtime.i18n import lazy_gettext as _

from oarepo_requests.proxies import current_oarepo_requests
from invenio_pidstore.errors import PersistentIdentifierError

if TYPE_CHECKING:
from flask_babel.speaklater import LazyString
from flask_principal import Identity
Expand Down
6 changes: 4 additions & 2 deletions oarepo_requests/resolvers/interface.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from __future__ import annotations

from typing import Any, TYPE_CHECKING
import logging
from typing import TYPE_CHECKING, Any

from invenio_pidstore.errors import PersistentIdentifierError

from oarepo_requests.resolvers.ui import resolve
import logging

if TYPE_CHECKING:
from invenio_requests.records import Request
log = logging.getLogger(__name__)


# todo consider - we are not using this strictly in the ui context - so how should we separate these things in the future
def resolve_entity(entity: str, obj: Request, ctx: dict[str, Any]) -> dict:
"""Resolve the entity and put it into the context cache.
Expand Down
8 changes: 4 additions & 4 deletions oarepo_requests/resources/events/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

from __future__ import annotations

import marshmallow as ma
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 OARepoRequestEventsUIJSONSerializer
import marshmallow as ma


class OARepoRequestsCommentsResourceConfig(
Expand All @@ -36,9 +36,9 @@ class OARepoRequestsCommentsResourceConfig(
@property
def request_item_view_args(self):
return {
**super().request_item_view_args,
"event_type": ma.fields.Str(),
}
**super().request_item_view_args,
"event_type": ma.fields.Str(),
}

@property
def response_handlers(self) -> dict[str, ResponseHandler]:
Expand Down
8 changes: 3 additions & 5 deletions oarepo_requests/resources/events/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

from __future__ import annotations

from flask_resources import route
from copy import deepcopy

from flask import g
from flask_resources import (
from_conf,
Expand Down Expand Up @@ -81,15 +78,16 @@ def search_extended(self) -> tuple[dict, int]:
"""Search for comments."""
return super().search()


# list args parser in invenio parses request_id input through UUID instead of Str; does this have any relevance for us?
@item_view_args_parser
@request_extra_args
@data_parser
@response_handler()
def create_event(self):
"""Create a comment."""
type_ = current_event_type_registry.lookup(resource_requestctx.view_args["event_type"], quiet=True)
type_ = current_event_type_registry.lookup(
resource_requestctx.view_args["event_type"], quiet=True
)
item = self.service.create(
identity=g.identity,
request_id=resource_requestctx.view_args["request_id"],
Expand Down
12 changes: 3 additions & 9 deletions oarepo_requests/services/permissions/generators/conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@
from invenio_requests.resolvers.registry import ResolverRegistry
from oarepo_runtime.datastreams.utils import get_record_service_for_record
from oarepo_workflows.requests import RecipientGeneratorMixin
from oarepo_workflows.requests.generators import (
IfEventType as WorkflowIfEventType,
)
from oarepo_workflows.requests.generators import (
IfRequestType as WorkflowIfRequestType,
)
from oarepo_workflows.requests.generators import (
IfRequestTypeBase,
)
from oarepo_workflows.requests.generators import IfEventType as WorkflowIfEventType
from oarepo_workflows.requests.generators import IfRequestType as WorkflowIfRequestType
from oarepo_workflows.requests.generators import IfRequestTypeBase
from sqlalchemy.exc import NoResultFound
from typing_extensions import deprecated

Expand Down
4 changes: 1 addition & 3 deletions oarepo_requests/services/record/types/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
from invenio_records_resources.services import LinksTemplate
from invenio_records_resources.services.base.links import Link

from oarepo_requests.services.results import (
RequestTypesList,
)
from oarepo_requests.services.results import RequestTypesList
from oarepo_requests.services.schema import RequestTypeSchema
from oarepo_requests.utils import allowed_request_types_for_record

Expand Down
Loading
Loading