File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import re
44from collections .abc import Iterable
5+ from typing import Any
56
67_BUBBLE_UID_PATTERN : re .Pattern [str ] = re .compile (r"^[0-9]+x[0-9]+$" )
78
89
9- def is_bubble_uid (value : str ) -> bool :
10+ def is_bubble_uid (value : Any ) -> bool :
1011 """Check if a string matches the Bubble UID format (e.g., '1767090310181x452059685440531200')."""
12+ if not isinstance (value , str ):
13+ return False
1114 return _BUBBLE_UID_PATTERN .fullmatch (value ) is not None
1215
1316
Original file line number Diff line number Diff line change @@ -19,6 +19,22 @@ def test_is_bubble_uid_valid(value: str) -> None:
1919 assert is_bubble_uid (value ) is True
2020
2121
22+ @pytest .mark .parametrize (
23+ ("value" , "reason" ),
24+ [
25+ (None , "None" ),
26+ (123 , "integer" ),
27+ (123.456 , "float" ),
28+ (["1x2" ], "list" ),
29+ ({"uid" : "1x2" }, "dict" ),
30+ (True , "boolean" ),
31+ ],
32+ )
33+ def test_is_bubble_uid_non_string (value : object , reason : str ) -> None :
34+ """Non-string values should return False without raising."""
35+ assert is_bubble_uid (value ) is False , f"should reject: { reason } "
36+
37+
2238@pytest .mark .parametrize (
2339 ("value" , "reason" ),
2440 [
You can’t perform that action at this time.
0 commit comments