Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Krist committed Jan 13, 2025
1 parent 6abb537 commit 200d465
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 40 deletions.
23 changes: 13 additions & 10 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
)
from invenio_records_resources.services.uow import RecordCommitOp
from invenio_requests.customizations import CommentEventType, LogEventType
from invenio_requests.proxies import current_requests, current_requests_service
from invenio_requests.records.api import Request, RequestEvent, RequestEventFormat
from invenio_requests.proxies import current_requests_service
from invenio_requests.records.api import Request, RequestEvent
from invenio_requests.services.generators import Receiver
from invenio_requests.services.permissions import (
PermissionPolicy as InvenioRequestsPermissionPolicy,
)
from invenio_users_resources.records import UserAggregate
from oarepo_runtime.i18n import lazy_gettext as _
from oarepo_runtime.services.permissions import RecordOwners
from oarepo_workflows import (
Expand All @@ -35,10 +34,8 @@
)
from oarepo_workflows.base import Workflow
from oarepo_workflows.requests.events import WorkflowEvent
from oarepo_workflows.requests.generators import RecipientGeneratorMixin
from pytest_oarepo.requests.classes import UserGenerator, TestEventType
from pytest_oarepo.requests.classes import TestEventType, UserGenerator
from thesis.proxies import current_service
from thesis.records.api import ThesisDraft

from oarepo_requests.actions.generic import (
OARepoAcceptAction,
Expand All @@ -58,20 +55,23 @@
from oarepo_requests.types.events.topic_update import TopicUpdateEventType

pytest_plugins = [
"pytest_oarepo.requests.fixtures",
"pytest_oarepo.records",
"pytest_oarepo.fixtures",
"pytest_oarepo.users",
"pytest_oarepo.requests.fixtures",
"pytest_oarepo.records",
"pytest_oarepo.fixtures",
"pytest_oarepo.users",
]


@pytest.fixture(scope="module", autouse=True)
def location(location):
return location


@pytest.fixture(autouse=True)
def vocab_cf(vocab_cf):
return vocab_cf


can_comment_only_receiver = [
Receiver(),
SystemProcess(),
Expand All @@ -88,6 +88,7 @@ def vocab_cf(vocab_cf):
TestEventType.type_id: WorkflowEvent(submitters=can_comment_only_receiver),
}


class DefaultRequests(WorkflowRequestPolicy):
publish_draft = WorkflowRequest(
requesters=[IfInState("draft", [RecordOwners()])],
Expand Down Expand Up @@ -435,10 +436,12 @@ def app_config(app_config):
app_config["FILES_REST_DEFAULT_STORAGE_CLASS"] = "L"
return app_config


@pytest.fixture(scope="module")
def record_service():
return current_service


@pytest.fixture
def check_publish_topic_update():
def _check_publish_topic_update(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_requests/test_create_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
# details.
#
import pytest
from pytest_oarepo.functions import link2testclient

from oarepo_requests.errors import OpenRequestAlreadyExists

from pytest_oarepo.functions import link2testclient


def test_can_create(
logged_client,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_requests/test_create_inmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# modify it under the terms of the MIT License; see LICENSE file for more
# details.
#
from thesis.records.api import ThesisRecord

from pytest_oarepo.functions import link2testclient
from thesis.records.api import ThesisRecord


# todo since inline is now the default way to create records, these might be redundant
Expand Down
3 changes: 1 addition & 2 deletions tests/test_requests/test_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# modify it under the terms of the MIT License; see LICENSE file for more
# details.
#
from thesis.records.api import ThesisDraft, ThesisRecord

from pytest_oarepo.functions import link2testclient
from thesis.records.api import ThesisDraft, ThesisRecord


def test_delete(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_requests/test_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# modify it under the terms of the MIT License; see LICENSE file for more
# details.
#
from thesis.records.api import ThesisDraft, ThesisRecord

from pytest_oarepo.functions import link2testclient
from thesis.records.api import ThesisDraft, ThesisRecord


def test_edit_autoaccept(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_requests/test_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
# details.
#
from invenio_requests.records.api import RequestEvent
from pytest_oarepo.functions import is_valid_subdict, link2testclient
from thesis.records.api import ThesisDraft


from pytest_oarepo.functions import link2testclient, is_valid_subdict

def test_listing(
logged_client,
users,
Expand Down
3 changes: 1 addition & 2 deletions tests/test_requests/test_new_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
# details.
#

from thesis.records.api import ThesisDraft, ThesisRecord

from pytest_oarepo.functions import link2testclient
from thesis.records.api import ThesisDraft, ThesisRecord


def test_new_version_autoaccept(
Expand Down
8 changes: 2 additions & 6 deletions tests/test_requests/test_param_interpreters.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ def _init(users, logged_client, draft_factory, submit_request, urls):
user1_client = logged_client(user1)
user2_client = logged_client(user2)

draft1 = draft_factory(
user1_client, custom_workflow="different_recipients"
)
draft2 = draft_factory(
user2_client, custom_workflow="different_recipients"
)
draft1 = draft_factory(user1_client, custom_workflow="different_recipients")
draft2 = draft_factory(user2_client, custom_workflow="different_recipients")

submit_response_user1 = submit_request(
user1_client, draft1, "publish_draft"
Expand Down
11 changes: 7 additions & 4 deletions tests/test_requests/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
#
import copy

from thesis.records.api import ThesisDraft, ThesisRecord

from pytest_oarepo.functions import link2testclient
from thesis.records.api import ThesisDraft, ThesisRecord


def test_publish_service(users, record_service, default_record_with_workflow_parent_json, search_clear):
def test_publish_service(
users, record_service, default_record_with_workflow_parent_json, search_clear
):
from invenio_requests.proxies import (
current_requests_service as current_invenio_requests_service,
)
Expand All @@ -21,7 +22,9 @@ def test_publish_service(users, record_service, default_record_with_workflow_par

creator = users[0]
receiver = users[1]
draft = record_service.create(creator.identity, default_record_with_workflow_parent_json)
draft = record_service.create(
creator.identity, default_record_with_workflow_parent_json
)
request = current_oarepo_requests_service.create(
identity=creator.identity,
data={"payload": {"version": "1.0"}},
Expand Down
3 changes: 1 addition & 2 deletions tests/test_requests/test_record_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
# modify it under the terms of the MIT License; see LICENSE file for more
# details.
#
from thesis.records.api import ThesisDraft, ThesisRecord

from pytest_oarepo.functions import link2testclient
from thesis.records.api import ThesisDraft, ThesisRecord


def test_read_requests_on_draft(
Expand Down
1 change: 0 additions & 1 deletion tests/test_requests/test_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# details.
#
from invenio_requests.records.api import RequestEvent

from pytest_oarepo.functions import link2testclient


Expand Down
3 changes: 1 addition & 2 deletions tests/test_requests/test_topic_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import json

from invenio_access.permissions import system_identity
from thesis.records.api import ThesisDraft, ThesisRecord

from pytest_oarepo.functions import link2testclient
from thesis.records.api import ThesisDraft, ThesisRecord


def test_resolve_topic(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_requests/test_ui_serialialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
from pprint import pprint

from deepdiff import DeepDiff
from pytest_oarepo.functions import link2testclient
from thesis.records.api import ThesisDraft, ThesisRecord

from oarepo_requests.resolvers.ui import FallbackEntityReferenceUIResolver

from pytest_oarepo.functions import link2testclient


def test_user_serialization(
users,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_requests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
from invenio_records_resources.services.uow import RecordCommitOp, unit_of_work
from invenio_requests.customizations.event_types import LogEventType
from invenio_requests.records.api import RequestEvent
from pytest_oarepo.functions import link2testclient
from thesis.records.api import ThesisDraft, ThesisRecord

from oarepo_requests.services.permissions.workflow_policies import (
CreatorsFromWorkflowRequestsPermissionPolicy,
)
from tests.conftest import TestEventType
from pytest_oarepo.functions import link2testclient


@unit_of_work()
Expand Down
1 change: 1 addition & 0 deletions tests/test_ui/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def extra_entry_points():
"""Extra entry points to load the mock_module features."""
return {"invenio_i18n.translations": ["1000-test = tests"]}


@pytest.fixture(scope="module")
def app_config(app_config):
app_config["I18N_LANGUAGES"] = [("cs", "Czech")]
Expand Down

0 comments on commit 200d465

Please sign in to comment.