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

fix: do not use test util in package #464

Merged
merged 5 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/momento/internal/_utilities/_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
TopicPermission,
TopicRole,
)
from tests.utils import str_to_bytes
from momento.utilities.shared_sync_asyncio import str_to_bytes


class SuperuserPermissions(PredefinedScope):
Expand Down
12 changes: 12 additions & 0 deletions src/momento/utilities/shared_sync_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,15 @@ def validate_disposable_token_expiry(expires_in: ExpiresIn) -> None:
raise ValueError("Disposable token expiry must be positive")
if expires_in.valid_for_seconds() > 60 * 60:
raise ValueError("Disposable tokens must expire within 1 hour")


def str_to_bytes(string: str) -> bytes:
"""Convert a string to bytes.

Args:
string (str): The string to convert.

Returns:
bytes: A UTF-8 byte representation of the string.
"""
return string.encode("utf-8")
Loading