Skip to content

Commit

Permalink
fix: do not use test util in package
Browse files Browse the repository at this point in the history
  • Loading branch information
anitarua committed Sep 23, 2024
1 parent 693a059 commit b170604
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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")

0 comments on commit b170604

Please sign in to comment.