-
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.
- Loading branch information
Showing
13 changed files
with
213 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[report] | ||
exclude_lines = | ||
pragma: no cover | ||
if TYPE_CHECKING: |
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,3 +1,7 @@ | ||
exclude = [ | ||
"tests" | ||
] | ||
|
||
[lint] | ||
extend-select = [ | ||
"UP", # pyupgrade | ||
|
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,33 @@ | ||
from oarepo_workflows.requests.generators import AutoApprove, auto_approve_need | ||
import pytest | ||
from invenio_requests.resolvers.registry import ResolverRegistry | ||
|
||
from oarepo_workflows.resolvers.auto_approve import AutoApproveProxy, AutoApproveEntity | ||
from invenio_access.permissions import system_identity | ||
|
||
|
||
def test_auto_approve_generator(): | ||
a = AutoApprove() | ||
|
||
with pytest.raises(ValueError): | ||
a.needs() | ||
|
||
with pytest.raises(ValueError): | ||
a.excludes() | ||
|
||
with pytest.raises(ValueError): | ||
a.query_filter() | ||
|
||
assert a.reference_receivers() == [{"auto_approve": "True"}] | ||
|
||
|
||
def test_auto_approve_resolver(app): | ||
resolved = ResolverRegistry.resolve_entity({"auto_approve": "True"}) | ||
assert isinstance(resolved, AutoApproveEntity) | ||
# | ||
# assert resolved.resolve() == AutoApprove() | ||
# assert resolved.pick_resolved_fields(system_identity, {"id": "true"}) == {"auto_approve": "true"} | ||
# assert resolved.get_needs() == [] | ||
|
||
entity_reference = ResolverRegistry.reference_entity(AutoApproveEntity()) | ||
assert entity_reference == {"auto_approve": "True"} |
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,6 @@ | ||
from oarepo_workflows import AutoRequest | ||
from oarepo_workflows.requests.generators import auto_request_need | ||
|
||
|
||
def test_auto_request_needs(app): | ||
assert AutoRequest().needs() == [auto_request_need] |
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
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,28 @@ | ||
from types import SimpleNamespace | ||
|
||
from oarepo_workflows import WorkflowPermission | ||
from oarepo_workflows.errors import MissingWorkflowError | ||
from thesis.thesis.records.api import ThesisRecord | ||
import pytest | ||
|
||
from flask_principal import Identity, UserNeed | ||
|
||
|
||
def test_get_workflow_id(users, logged_client, search_clear, record_service): | ||
thesis = ThesisRecord.create({}) | ||
wp = WorkflowPermission("read") | ||
with pytest.raises(MissingWorkflowError): | ||
wp._get_workflow_id(record=thesis) | ||
|
||
fake_thesis = SimpleNamespace(parent=SimpleNamespace(workflow="")) | ||
with pytest.raises(MissingWorkflowError): | ||
assert wp._get_workflow_id(record=fake_thesis) # noqa | ||
|
||
def test_query_filter(users, logged_client, search_clear, record_service): | ||
wp = WorkflowPermission("read") | ||
|
||
id1 = Identity(id=1) | ||
id1.provides.add(UserNeed(1)) | ||
|
||
with pytest.raises(MissingWorkflowError): | ||
assert wp.query_filter(identity=id1) == {} |
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