-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Non experimental scope parsing sc 30765 (#966)
* Migrate existing scope tests to new path * Non-experimental Scope Parsing * Update changelog.d/20240322_122646_derek_non_experimental_scope_parsing_sc_30765.rst Co-authored-by: Stephen Rosen <sirosen@globus.org> --------- Co-authored-by: Stephen Rosen <sirosen@globus.org>
- Loading branch information
1 parent
261f3fb
commit f60c9a3
Showing
16 changed files
with
118 additions
and
342 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
changelog.d/20240322_122646_derek_non_experimental_scope_parsing_sc_30765.rst
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 @@ | ||
|
||
Added | ||
~~~~~ | ||
|
||
- Moved scope parsing out of experimental. The ``Scope`` construct is now importable from | ||
the top level `globus_sdk` module. (:pr:`NUMBER`) |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
""" | ||
Scope parsing has been moved out of experimental into the main SDK. | ||
This module will be removed in a future release but is maintained in the interim for | ||
backwards compatibility. | ||
""" | ||
|
||
from globus_sdk.scopes import Scope, ScopeCycleError, ScopeParseError | ||
|
||
__all__ = ( | ||
"Scope", | ||
"ScopeParseError", | ||
"ScopeCycleError", | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
""" | ||
Constructs which are added to `experimental` ultimately (hopefully) get ported over to | ||
the main `globus_sdk` namespace. | ||
The tests in this module verify that those constructs are still available from the | ||
`globus_sdk.experimental` namespace (for backwards compatibility). | ||
Eventually these constructs do get deprecated at which point the tests in this module | ||
can be deleted. | ||
""" | ||
|
||
|
||
def test_scope_importable_from_experimental(): | ||
from globus_sdk.experimental.scope_parser import ( # noqa: F401 | ||
Scope, | ||
ScopeCycleError, | ||
ScopeParseError, | ||
) |
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,48 @@ | ||
import pytest | ||
|
||
from globus_sdk.scopes import MutableScope | ||
|
||
|
||
def test_scope_str_and_repr_simple(): | ||
s = MutableScope("simple") | ||
assert str(s) == "simple" | ||
assert repr(s) == "MutableScope('simple')" | ||
|
||
|
||
def test_scope_str_and_repr_optional(): | ||
s = MutableScope("simple", optional=True) | ||
assert str(s) == "*simple" | ||
assert repr(s) == "MutableScope('simple', optional=True)" | ||
|
||
|
||
def test_scope_str_and_repr_with_dependencies(): | ||
s = MutableScope("top") | ||
s.add_dependency("foo") | ||
assert str(s) == "top[foo]" | ||
s.add_dependency("bar") | ||
assert str(s) == "top[foo bar]" | ||
assert ( | ||
repr(s) == "MutableScope('top', " | ||
"dependencies=[MutableScope('foo'), MutableScope('bar')])" | ||
) | ||
|
||
|
||
def test_add_dependency_warns_on_optional_but_still_has_good_str_and_repr(): | ||
s = MutableScope("top") | ||
# this should warn, the use of `optional=...` rather than adding a Scope object | ||
# when optional dependencies are wanted is deprecated | ||
with pytest.warns(DeprecationWarning): | ||
s.add_dependency("foo", optional=True) | ||
|
||
# confirm the str representation and repr for good measure | ||
assert str(s) == "top[*foo]" | ||
assert ( | ||
repr(s) | ||
== "MutableScope('top', dependencies=[MutableScope('foo', optional=True)])" | ||
) | ||
|
||
|
||
@pytest.mark.parametrize("scope_str", ("*foo", "foo[bar]", "foo[", "foo]", "foo bar")) | ||
def test_scope_init_forbids_special_chars(scope_str): | ||
with pytest.raises(ValueError): | ||
MutableScope(scope_str) |
Oops, something went wrong.